promogame-player 0.0.25 → 0.0.27
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,6 +1,7 @@
|
|
|
1
1
|
import { EventName } from '../../types.ts';
|
|
2
|
+
import { PromogamePlayerHandle } from './unity-game.tsx';
|
|
2
3
|
import * as React from 'react';
|
|
3
|
-
export interface PromogamePlayerProps extends React.RefAttributes<
|
|
4
|
+
export interface PromogamePlayerProps extends React.RefAttributes<PromogamePlayerHandle> {
|
|
4
5
|
apiUrl: string;
|
|
5
6
|
campaignId?: string;
|
|
6
7
|
checksum?: string;
|
|
@@ -18,4 +19,4 @@ export interface PromogamePlayerProps extends React.RefAttributes<HTMLCanvasElem
|
|
|
18
19
|
registerEvents?: EventName[];
|
|
19
20
|
onEventReceived?: (eventName: EventName, params: unknown) => void;
|
|
20
21
|
}
|
|
21
|
-
export declare const PromogamePlayer: React.ForwardRefExoticComponent<Omit<PromogamePlayerProps, "ref"> & React.RefAttributes<
|
|
22
|
+
export declare const PromogamePlayer: React.ForwardRefExoticComponent<Omit<PromogamePlayerProps, "ref"> & React.RefAttributes<PromogamePlayerHandle>>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { EventName } from '../../types.ts';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
export interface PromogamePlayerHandle {
|
|
4
|
+
unload: () => void;
|
|
5
|
+
canvas?: HTMLCanvasElement | null;
|
|
6
|
+
}
|
|
3
7
|
export interface UnityGameProps extends React.RefAttributes<HTMLCanvasElement> {
|
|
4
8
|
gameLink?: string;
|
|
5
9
|
loadingComponent?: React.ComponentType<{
|
|
@@ -9,4 +13,4 @@ export interface UnityGameProps extends React.RefAttributes<HTMLCanvasElement> {
|
|
|
9
13
|
registerEvents?: EventName[];
|
|
10
14
|
onEventReceived?: (eventName: EventName, params: unknown) => void;
|
|
11
15
|
}
|
|
12
|
-
export declare const UnityGame: React.ForwardRefExoticComponent<Omit<UnityGameProps, "ref"> & React.RefAttributes<
|
|
16
|
+
export declare const UnityGame: React.ForwardRefExoticComponent<Omit<UnityGameProps, "ref"> & React.RefAttributes<PromogamePlayerHandle>>;
|
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
import { jsxs as P, Fragment as
|
|
2
|
-
import * as
|
|
3
|
-
import g, { useRef as
|
|
4
|
-
import { cn as
|
|
5
|
-
var j = {}, L = {}, S = {},
|
|
6
|
-
function
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
var l = g, c = 0,
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
1
|
+
import { jsxs as P, Fragment as ce, jsx as $ } from "react/jsx-runtime";
|
|
2
|
+
import * as de from "react";
|
|
3
|
+
import g, { useRef as B, useImperativeHandle as ve, useEffect as F } from "react";
|
|
4
|
+
import { cn as fe } from "../../utils.js";
|
|
5
|
+
var j = {}, L = {}, S = {}, G;
|
|
6
|
+
function ye() {
|
|
7
|
+
if (G) return S;
|
|
8
|
+
G = 1, Object.defineProperty(S, "__esModule", { value: !0 }), S.useUnityCanvasId = void 0;
|
|
9
|
+
var l = g, c = 0, i = "react-unity-webgl-canvas", y = function(f) {
|
|
10
|
+
if (f.id !== void 0)
|
|
11
|
+
return f.id;
|
|
12
12
|
var b = (0, l.useMemo)(function() {
|
|
13
|
-
return [
|
|
13
|
+
return [i, ++c].join("-");
|
|
14
14
|
}, []);
|
|
15
15
|
return b;
|
|
16
16
|
};
|
|
17
17
|
return S.useUnityCanvasId = y, S;
|
|
18
18
|
}
|
|
19
|
-
var w = {}, p = {},
|
|
20
|
-
function
|
|
21
|
-
if (
|
|
22
|
-
|
|
19
|
+
var w = {}, p = {}, T;
|
|
20
|
+
function ee() {
|
|
21
|
+
if (T) return p;
|
|
22
|
+
T = 1, Object.defineProperty(p, "__esModule", { value: !0 }), p.UnityLoaderStatus = void 0;
|
|
23
23
|
var l;
|
|
24
24
|
return function(c) {
|
|
25
25
|
c.Idle = "Idle", c.Loading = "Loading", c.Loaded = "Loaded", c.Error = "Error";
|
|
26
26
|
}(l || (p.UnityLoaderStatus = l = {})), p;
|
|
27
27
|
}
|
|
28
|
-
var q = {},
|
|
28
|
+
var q = {}, D;
|
|
29
29
|
function A() {
|
|
30
|
-
return
|
|
30
|
+
return D || (D = 1, Object.defineProperty(q, "__esModule", { value: !0 }), q.isBrowserEnvironment = void 0, q.isBrowserEnvironment = typeof window < "u" && typeof document < "u"), q;
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
function
|
|
34
|
-
if (
|
|
35
|
-
|
|
32
|
+
var z;
|
|
33
|
+
function Ue() {
|
|
34
|
+
if (z) return w;
|
|
35
|
+
z = 1;
|
|
36
36
|
var l = w && w.__awaiter || function(m, o, n, e) {
|
|
37
|
-
function
|
|
37
|
+
function s(r) {
|
|
38
38
|
return r instanceof n ? r : new n(function(t) {
|
|
39
39
|
t(r);
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
return new (n || (n = Promise))(function(r, t) {
|
|
43
|
-
function d(
|
|
43
|
+
function d(a) {
|
|
44
44
|
try {
|
|
45
|
-
|
|
46
|
-
} catch (
|
|
47
|
-
t(
|
|
45
|
+
u(e.next(a));
|
|
46
|
+
} catch (v) {
|
|
47
|
+
t(v);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function U(a) {
|
|
51
51
|
try {
|
|
52
|
-
|
|
53
|
-
} catch (
|
|
54
|
-
t(
|
|
52
|
+
u(e.throw(a));
|
|
53
|
+
} catch (v) {
|
|
54
|
+
t(v);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
57
|
+
function u(a) {
|
|
58
|
+
a.done ? r(a.value) : s(a.value).then(d, U);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
u((e = e.apply(m, o || [])).next());
|
|
61
61
|
});
|
|
62
62
|
}, c = w && w.__generator || function(m, o) {
|
|
63
63
|
var n = { label: 0, sent: function() {
|
|
64
64
|
if (r[0] & 1) throw r[1];
|
|
65
65
|
return r[1];
|
|
66
|
-
}, trys: [], ops: [] }, e,
|
|
66
|
+
}, trys: [], ops: [] }, e, s, r, t = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
|
|
67
67
|
return t.next = d(0), t.throw = d(1), t.return = d(2), typeof Symbol == "function" && (t[Symbol.iterator] = function() {
|
|
68
68
|
return this;
|
|
69
69
|
}), t;
|
|
70
|
-
function d(
|
|
71
|
-
return function(
|
|
72
|
-
return
|
|
70
|
+
function d(u) {
|
|
71
|
+
return function(a) {
|
|
72
|
+
return U([u, a]);
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function U(u) {
|
|
76
76
|
if (e) throw new TypeError("Generator is already executing.");
|
|
77
|
-
for (; t && (t = 0,
|
|
78
|
-
if (e = 1,
|
|
79
|
-
switch (
|
|
77
|
+
for (; t && (t = 0, u[0] && (n = 0)), n; ) try {
|
|
78
|
+
if (e = 1, s && (r = u[0] & 2 ? s.return : u[0] ? s.throw || ((r = s.return) && r.call(s), 0) : s.next) && !(r = r.call(s, u[1])).done) return r;
|
|
79
|
+
switch (s = 0, r && (u = [u[0] & 2, r.value]), u[0]) {
|
|
80
80
|
case 0:
|
|
81
81
|
case 1:
|
|
82
|
-
r =
|
|
82
|
+
r = u;
|
|
83
83
|
break;
|
|
84
84
|
case 4:
|
|
85
|
-
return n.label++, { value:
|
|
85
|
+
return n.label++, { value: u[1], done: !1 };
|
|
86
86
|
case 5:
|
|
87
|
-
n.label++,
|
|
87
|
+
n.label++, s = u[1], u = [0];
|
|
88
88
|
continue;
|
|
89
89
|
case 7:
|
|
90
|
-
|
|
90
|
+
u = n.ops.pop(), n.trys.pop();
|
|
91
91
|
continue;
|
|
92
92
|
default:
|
|
93
|
-
if (r = n.trys, !(r = r.length > 0 && r[r.length - 1]) && (
|
|
93
|
+
if (r = n.trys, !(r = r.length > 0 && r[r.length - 1]) && (u[0] === 6 || u[0] === 2)) {
|
|
94
94
|
n = 0;
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
97
|
-
if (
|
|
98
|
-
n.label =
|
|
97
|
+
if (u[0] === 3 && (!r || u[1] > r[0] && u[1] < r[3])) {
|
|
98
|
+
n.label = u[1];
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
102
|
-
n.label = r[1], r =
|
|
101
|
+
if (u[0] === 6 && n.label < r[1]) {
|
|
102
|
+
n.label = r[1], r = u;
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
105
|
if (r && n.label < r[2]) {
|
|
106
|
-
n.label = r[2], n.ops.push(
|
|
106
|
+
n.label = r[2], n.ops.push(u);
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
109
109
|
r[2] && n.ops.pop(), n.trys.pop();
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
} catch (
|
|
114
|
-
|
|
112
|
+
u = o.call(m, n);
|
|
113
|
+
} catch (a) {
|
|
114
|
+
u = [6, a], s = 0;
|
|
115
115
|
} finally {
|
|
116
116
|
e = r = 0;
|
|
117
117
|
}
|
|
118
|
-
if (
|
|
119
|
-
return { value:
|
|
118
|
+
if (u[0] & 5) throw u[1];
|
|
119
|
+
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
Object.defineProperty(w, "__esModule", { value: !0 }), w.useUnityInstance = void 0;
|
|
123
|
-
var
|
|
124
|
-
(0,
|
|
123
|
+
var i = g, y = ee(), f = A(), b = function(m, o, n, e) {
|
|
124
|
+
(0, i.useEffect)(function() {
|
|
125
125
|
(function() {
|
|
126
126
|
return l(void 0, void 0, void 0, function() {
|
|
127
|
-
var
|
|
127
|
+
var s, r;
|
|
128
128
|
return c(this, function(t) {
|
|
129
129
|
switch (t.label) {
|
|
130
130
|
case 0:
|
|
131
|
-
if (
|
|
131
|
+
if (f.isBrowserEnvironment === !1)
|
|
132
132
|
return [
|
|
133
133
|
2
|
|
134
134
|
/*return*/
|
|
@@ -142,7 +142,7 @@ function ye() {
|
|
|
142
142
|
case 1:
|
|
143
143
|
return t.trys.push([1, 3, , 4]), [4, window.createUnityInstance(o, n, e.setLoadingProgression)];
|
|
144
144
|
case 2:
|
|
145
|
-
return
|
|
145
|
+
return s = t.sent(), e.setUnityInstance(s), e.setInitialisationError(null), [3, 4];
|
|
146
146
|
case 3:
|
|
147
147
|
return r = t.sent(), e.setUnityInstance(null), e.setInitialisationError(r), [3, 4];
|
|
148
148
|
case 4:
|
|
@@ -158,55 +158,55 @@ function ye() {
|
|
|
158
158
|
};
|
|
159
159
|
return w.useUnityInstance = b, w;
|
|
160
160
|
}
|
|
161
|
-
var M = {},
|
|
162
|
-
function
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
var l = g, c = function(
|
|
161
|
+
var M = {}, V;
|
|
162
|
+
function me() {
|
|
163
|
+
if (V) return M;
|
|
164
|
+
V = 1, Object.defineProperty(M, "__esModule", { value: !0 }), M.useUnityArguments = void 0;
|
|
165
|
+
var l = g, c = function(i) {
|
|
166
166
|
return (0, l.useMemo)(function() {
|
|
167
167
|
return {
|
|
168
168
|
// Assigns the data URL, framework URL, and code URL to the Unity
|
|
169
169
|
// arguments object.
|
|
170
|
-
dataUrl:
|
|
171
|
-
frameworkUrl:
|
|
172
|
-
codeUrl:
|
|
170
|
+
dataUrl: i.unityProvider.unityConfig.dataUrl,
|
|
171
|
+
frameworkUrl: i.unityProvider.unityConfig.frameworkUrl,
|
|
172
|
+
codeUrl: i.unityProvider.unityConfig.codeUrl,
|
|
173
173
|
// Assigns the optional streaming assets URL, memory URL, symbols URL,
|
|
174
174
|
// and worker URL to the Unity arguments object.
|
|
175
|
-
streamingAssetsUrl:
|
|
176
|
-
memoryUrl:
|
|
177
|
-
symbolsUrl:
|
|
178
|
-
workerUrl:
|
|
175
|
+
streamingAssetsUrl: i.unityProvider.unityConfig.streamingAssetsUrl,
|
|
176
|
+
memoryUrl: i.unityProvider.unityConfig.memoryUrl,
|
|
177
|
+
symbolsUrl: i.unityProvider.unityConfig.symbolsUrl,
|
|
178
|
+
workerUrl: i.unityProvider.unityConfig.workerUrl,
|
|
179
179
|
// Assigns the optional company name, product name, and product version to
|
|
180
180
|
// the Unity arguments object.
|
|
181
|
-
companyName:
|
|
182
|
-
productName:
|
|
183
|
-
productVersion:
|
|
181
|
+
companyName: i.unityProvider.unityConfig.companyName,
|
|
182
|
+
productName: i.unityProvider.unityConfig.productName,
|
|
183
|
+
productVersion: i.unityProvider.unityConfig.productVersion,
|
|
184
184
|
// Assigns the webgl context attributes to the Unity arguments object.
|
|
185
185
|
// If the webgl context attributes are not defined via the Unity Props,
|
|
186
186
|
// the default value of an empty object will be used.
|
|
187
|
-
webglContextAttributes:
|
|
187
|
+
webglContextAttributes: i.unityProvider.unityConfig.webglContextAttributes || {},
|
|
188
188
|
// Assigns the cache control value to the Unity arguments object. If the
|
|
189
189
|
// cache control value is not defined via the Unity Props, the default
|
|
190
190
|
// value of always `must-revalidate` will be used.
|
|
191
|
-
cacheControl:
|
|
191
|
+
cacheControl: i.unityProvider.unityConfig.cacheControl || function() {
|
|
192
192
|
return "must-revalidate";
|
|
193
193
|
},
|
|
194
194
|
// Assigns the device pixel ratio to the Unity arguments object. If the
|
|
195
195
|
// device pixel ratio is not defined via the Unity Props, the default
|
|
196
196
|
// value of `1` will be used.
|
|
197
|
-
devicePixelRatio:
|
|
197
|
+
devicePixelRatio: i.devicePixelRatio || 1,
|
|
198
198
|
// Assigns the auto sync persistent data path value to the Unity arguments
|
|
199
199
|
// object. If the auto sync persistent data path value is not defined via
|
|
200
200
|
// the Unity Props, the default value of `undefined` will be used.
|
|
201
|
-
autoSyncPersistentDataPath:
|
|
201
|
+
autoSyncPersistentDataPath: i.autoSyncPersistentDataPath,
|
|
202
202
|
// Assigns the match WebGL to canvas size value to the Unity arguments
|
|
203
203
|
// object. If the match WebGL to canvas size value is not defined via the
|
|
204
204
|
// Unity Props, the default value of `true` will be used.
|
|
205
|
-
matchWebGLToCanvasSize: typeof
|
|
205
|
+
matchWebGLToCanvasSize: typeof i.matchWebGLToCanvasSize == "boolean" ? i.matchWebGLToCanvasSize : !0,
|
|
206
206
|
// Assigns the disabled canvas events to the Unity arguments object. If
|
|
207
207
|
// the disabled canvas events are not defined via the Unity Props, the
|
|
208
208
|
// default value of `contextmenu` and `dragstart` will be used.
|
|
209
|
-
disabledCanvasEvents:
|
|
209
|
+
disabledCanvasEvents: i.disabledCanvasEvents || [
|
|
210
210
|
"contextmenu",
|
|
211
211
|
"dragstart"
|
|
212
212
|
],
|
|
@@ -237,52 +237,52 @@ function Ue() {
|
|
|
237
237
|
};
|
|
238
238
|
return M.useUnityArguments = c, M;
|
|
239
239
|
}
|
|
240
|
-
var x = {},
|
|
241
|
-
function
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
var l = g, c = A(),
|
|
245
|
-
var b = (0, l.useState)(
|
|
240
|
+
var x = {}, W;
|
|
241
|
+
function be() {
|
|
242
|
+
if (W) return x;
|
|
243
|
+
W = 1, Object.defineProperty(x, "__esModule", { value: !0 }), x.useUnityLoader = void 0;
|
|
244
|
+
var l = g, c = A(), i = ee(), y = function(f) {
|
|
245
|
+
var b = (0, l.useState)(i.UnityLoaderStatus.Loading), m = b[0], o = b[1];
|
|
246
246
|
return (0, l.useEffect)(function() {
|
|
247
247
|
if (c.isBrowserEnvironment !== !1) {
|
|
248
|
-
if (
|
|
249
|
-
o(
|
|
248
|
+
if (f.loaderUrl === null) {
|
|
249
|
+
o(i.UnityLoaderStatus.Idle);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
-
var n = window.document.querySelector('script[src="'.concat(
|
|
253
|
-
n === null ? (n = window.document.createElement("script"), n.type = "text/javascript", n.src =
|
|
252
|
+
var n = window.document.querySelector('script[src="'.concat(f.loaderUrl, '"]'));
|
|
253
|
+
n === null ? (n = window.document.createElement("script"), n.type = "text/javascript", n.src = f.loaderUrl, n.async = !0, n.setAttribute("data-status", "loading"), window.document.body.appendChild(n), n.addEventListener("load", function() {
|
|
254
254
|
return n == null ? void 0 : n.setAttribute("data-status", "loaded");
|
|
255
255
|
}), n.addEventListener("error", function() {
|
|
256
256
|
return n == null ? void 0 : n.setAttribute("data-status", "error");
|
|
257
|
-
})) : o(n.getAttribute("data-status") === "loaded" ?
|
|
258
|
-
var e = function(
|
|
259
|
-
return o(
|
|
257
|
+
})) : o(n.getAttribute("data-status") === "loaded" ? i.UnityLoaderStatus.Loaded : i.UnityLoaderStatus.Error);
|
|
258
|
+
var e = function(s) {
|
|
259
|
+
return o(s.type === "load" ? i.UnityLoaderStatus.Loaded : i.UnityLoaderStatus.Error);
|
|
260
260
|
};
|
|
261
261
|
return n.addEventListener("load", e), n.addEventListener("error", e), function() {
|
|
262
262
|
n !== null && (n.removeEventListener("load", e), n.removeEventListener("error", e), window.document.body.removeChild(n));
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
}, [
|
|
265
|
+
}, [f.loaderUrl]), m;
|
|
266
266
|
};
|
|
267
267
|
return x.useUnityLoader = y, x;
|
|
268
268
|
}
|
|
269
|
-
var
|
|
270
|
-
function
|
|
271
|
-
if (
|
|
272
|
-
|
|
273
|
-
var l = g, c = g,
|
|
269
|
+
var H;
|
|
270
|
+
function _e() {
|
|
271
|
+
if (H) return L;
|
|
272
|
+
H = 1, Object.defineProperty(L, "__esModule", { value: !0 }), L.Unity = void 0;
|
|
273
|
+
var l = g, c = g, i = ye(), y = Ue(), f = me(), b = be(), m = (0, c.forwardRef)(
|
|
274
274
|
/**
|
|
275
275
|
* @param unityProps The Unity props provided the the Unity component.
|
|
276
276
|
* @param forwardedRef The forwarded ref to the Unity component.
|
|
277
277
|
* @returns The Unity canvas renderer.
|
|
278
278
|
*/
|
|
279
279
|
function(o, n) {
|
|
280
|
-
var e = (0, c.useRef)(null),
|
|
280
|
+
var e = (0, c.useRef)(null), s = (0, i.useUnityCanvasId)(o), r = (0, f.useUnityArguments)(o), t = (0, b.useUnityLoader)(o.unityProvider.unityConfig);
|
|
281
281
|
return (0, y.useUnityInstance)(t, e.current, r, o.unityProvider), (0, l.useImperativeHandle)(n, function() {
|
|
282
282
|
return e.current;
|
|
283
283
|
}), (0, l.createElement)("canvas", {
|
|
284
284
|
ref: e,
|
|
285
|
-
id:
|
|
285
|
+
id: s,
|
|
286
286
|
style: o.style,
|
|
287
287
|
className: o.className,
|
|
288
288
|
tabIndex: o.tabIndex
|
|
@@ -292,7 +292,7 @@ function be() {
|
|
|
292
292
|
return L.Unity = m, L;
|
|
293
293
|
}
|
|
294
294
|
var h = {}, k = {}, Q;
|
|
295
|
-
function
|
|
295
|
+
function te() {
|
|
296
296
|
if (Q) return k;
|
|
297
297
|
Q = 1, Object.defineProperty(k, "__esModule", { value: !0 }), k.errorMessages = void 0;
|
|
298
298
|
var l = {
|
|
@@ -333,23 +333,23 @@ function ee() {
|
|
|
333
333
|
};
|
|
334
334
|
return k.errorMessages = l, k;
|
|
335
335
|
}
|
|
336
|
-
var
|
|
337
|
-
function
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
var l =
|
|
341
|
-
if (e || arguments.length === 2) for (var
|
|
342
|
-
(t || !(
|
|
336
|
+
var E = {}, J;
|
|
337
|
+
function we() {
|
|
338
|
+
if (J) return E;
|
|
339
|
+
J = 1;
|
|
340
|
+
var l = E && E.__spreadArray || function(o, n, e) {
|
|
341
|
+
if (e || arguments.length === 2) for (var s = 0, r = n.length, t; s < r; s++)
|
|
342
|
+
(t || !(s in n)) && (t || (t = Array.prototype.slice.call(n, 0, s)), t[s] = n[s]);
|
|
343
343
|
return o.concat(t || Array.prototype.slice.call(n));
|
|
344
344
|
};
|
|
345
|
-
Object.defineProperty(
|
|
346
|
-
var c = g,
|
|
345
|
+
Object.defineProperty(E, "__esModule", { value: !0 }), E.useEventSystem = void 0;
|
|
346
|
+
var c = g, i = te(), y = A(), f = [], b = function(o) {
|
|
347
347
|
for (var n = [], e = 1; e < arguments.length; e++)
|
|
348
348
|
n[e - 1] = arguments[e];
|
|
349
|
-
var
|
|
350
|
-
return
|
|
351
|
-
|
|
352
|
-
}),
|
|
349
|
+
var s = void 0;
|
|
350
|
+
return f.forEach(function(r) {
|
|
351
|
+
s = r.apply(void 0, l([o], n, !1));
|
|
352
|
+
}), s;
|
|
353
353
|
};
|
|
354
354
|
y.isBrowserEnvironment === !0 && (window.dispatchReactUnityEvent = b);
|
|
355
355
|
var m = function() {
|
|
@@ -375,7 +375,7 @@ function _e() {
|
|
|
375
375
|
});
|
|
376
376
|
},
|
|
377
377
|
[o]
|
|
378
|
-
),
|
|
378
|
+
), s = (0, c.useCallback)(
|
|
379
379
|
/**
|
|
380
380
|
* @param eventName The name of the event to dispatch.
|
|
381
381
|
* @param parameters The parameters to pass to the event listener.
|
|
@@ -383,136 +383,136 @@ function _e() {
|
|
|
383
383
|
function(r) {
|
|
384
384
|
for (var t = [], d = 1; d < arguments.length; d++)
|
|
385
385
|
t[d - 1] = arguments[d];
|
|
386
|
-
var
|
|
387
|
-
return
|
|
386
|
+
var U = o.current.find(function(u) {
|
|
387
|
+
return u.eventName === r;
|
|
388
388
|
});
|
|
389
|
-
if (typeof
|
|
390
|
-
console.warn(
|
|
389
|
+
if (typeof U > "u") {
|
|
390
|
+
console.warn(i.errorMessages.noEventListener, { eventName: r });
|
|
391
391
|
return;
|
|
392
392
|
}
|
|
393
|
-
return
|
|
393
|
+
return U.callback.apply(U, t);
|
|
394
394
|
},
|
|
395
395
|
[o]
|
|
396
396
|
);
|
|
397
397
|
return (0, c.useEffect)(function() {
|
|
398
|
-
return
|
|
399
|
-
|
|
398
|
+
return f.push(s), function() {
|
|
399
|
+
f.splice(f.indexOf(s), 1);
|
|
400
400
|
};
|
|
401
|
-
}, [
|
|
401
|
+
}, [s]), {
|
|
402
402
|
addEventListener: n,
|
|
403
403
|
removeEventListener: e
|
|
404
404
|
};
|
|
405
405
|
};
|
|
406
|
-
return
|
|
406
|
+
return E.useEventSystem = m, E;
|
|
407
407
|
}
|
|
408
|
-
var N = {},
|
|
409
|
-
function
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
var l = g, c = function(
|
|
413
|
-
return (0, l.useState)(
|
|
408
|
+
var N = {}, K;
|
|
409
|
+
function he() {
|
|
410
|
+
if (K) return N;
|
|
411
|
+
K = 1, Object.defineProperty(N, "__esModule", { value: !0 }), N.useNullableState = void 0;
|
|
412
|
+
var l = g, c = function(i) {
|
|
413
|
+
return (0, l.useState)(i || null);
|
|
414
414
|
};
|
|
415
415
|
return N.useNullableState = c, N;
|
|
416
416
|
}
|
|
417
|
-
var
|
|
418
|
-
function
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
var l = h && h.__awaiter || function(o, n, e,
|
|
417
|
+
var X;
|
|
418
|
+
function ge() {
|
|
419
|
+
if (X) return h;
|
|
420
|
+
X = 1;
|
|
421
|
+
var l = h && h.__awaiter || function(o, n, e, s) {
|
|
422
422
|
function r(t) {
|
|
423
423
|
return t instanceof e ? t : new e(function(d) {
|
|
424
424
|
d(t);
|
|
425
425
|
});
|
|
426
426
|
}
|
|
427
427
|
return new (e || (e = Promise))(function(t, d) {
|
|
428
|
-
function
|
|
428
|
+
function U(v) {
|
|
429
429
|
try {
|
|
430
|
-
|
|
431
|
-
} catch (
|
|
432
|
-
d(
|
|
430
|
+
a(s.next(v));
|
|
431
|
+
} catch (I) {
|
|
432
|
+
d(I);
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function u(v) {
|
|
436
436
|
try {
|
|
437
|
-
|
|
438
|
-
} catch (
|
|
439
|
-
d(
|
|
437
|
+
a(s.throw(v));
|
|
438
|
+
} catch (I) {
|
|
439
|
+
d(I);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
function
|
|
443
|
-
|
|
442
|
+
function a(v) {
|
|
443
|
+
v.done ? t(v.value) : r(v.value).then(U, u);
|
|
444
444
|
}
|
|
445
|
-
|
|
445
|
+
a((s = s.apply(o, n || [])).next());
|
|
446
446
|
});
|
|
447
447
|
}, c = h && h.__generator || function(o, n) {
|
|
448
448
|
var e = { label: 0, sent: function() {
|
|
449
449
|
if (t[0] & 1) throw t[1];
|
|
450
450
|
return t[1];
|
|
451
|
-
}, trys: [], ops: [] },
|
|
452
|
-
return d.next =
|
|
451
|
+
}, trys: [], ops: [] }, s, r, t, d = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
|
|
452
|
+
return d.next = U(0), d.throw = U(1), d.return = U(2), typeof Symbol == "function" && (d[Symbol.iterator] = function() {
|
|
453
453
|
return this;
|
|
454
454
|
}), d;
|
|
455
|
-
function
|
|
456
|
-
return function(
|
|
457
|
-
return
|
|
455
|
+
function U(a) {
|
|
456
|
+
return function(v) {
|
|
457
|
+
return u([a, v]);
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
|
-
function
|
|
461
|
-
if (
|
|
462
|
-
for (; d && (d = 0,
|
|
463
|
-
if (
|
|
464
|
-
switch (r = 0, t && (
|
|
460
|
+
function u(a) {
|
|
461
|
+
if (s) throw new TypeError("Generator is already executing.");
|
|
462
|
+
for (; d && (d = 0, a[0] && (e = 0)), e; ) try {
|
|
463
|
+
if (s = 1, r && (t = a[0] & 2 ? r.return : a[0] ? r.throw || ((t = r.return) && t.call(r), 0) : r.next) && !(t = t.call(r, a[1])).done) return t;
|
|
464
|
+
switch (r = 0, t && (a = [a[0] & 2, t.value]), a[0]) {
|
|
465
465
|
case 0:
|
|
466
466
|
case 1:
|
|
467
|
-
t =
|
|
467
|
+
t = a;
|
|
468
468
|
break;
|
|
469
469
|
case 4:
|
|
470
|
-
return e.label++, { value:
|
|
470
|
+
return e.label++, { value: a[1], done: !1 };
|
|
471
471
|
case 5:
|
|
472
|
-
e.label++, r =
|
|
472
|
+
e.label++, r = a[1], a = [0];
|
|
473
473
|
continue;
|
|
474
474
|
case 7:
|
|
475
|
-
|
|
475
|
+
a = e.ops.pop(), e.trys.pop();
|
|
476
476
|
continue;
|
|
477
477
|
default:
|
|
478
|
-
if (t = e.trys, !(t = t.length > 0 && t[t.length - 1]) && (
|
|
478
|
+
if (t = e.trys, !(t = t.length > 0 && t[t.length - 1]) && (a[0] === 6 || a[0] === 2)) {
|
|
479
479
|
e = 0;
|
|
480
480
|
continue;
|
|
481
481
|
}
|
|
482
|
-
if (
|
|
483
|
-
e.label =
|
|
482
|
+
if (a[0] === 3 && (!t || a[1] > t[0] && a[1] < t[3])) {
|
|
483
|
+
e.label = a[1];
|
|
484
484
|
break;
|
|
485
485
|
}
|
|
486
|
-
if (
|
|
487
|
-
e.label = t[1], t =
|
|
486
|
+
if (a[0] === 6 && e.label < t[1]) {
|
|
487
|
+
e.label = t[1], t = a;
|
|
488
488
|
break;
|
|
489
489
|
}
|
|
490
490
|
if (t && e.label < t[2]) {
|
|
491
|
-
e.label = t[2], e.ops.push(
|
|
491
|
+
e.label = t[2], e.ops.push(a);
|
|
492
492
|
break;
|
|
493
493
|
}
|
|
494
494
|
t[2] && e.ops.pop(), e.trys.pop();
|
|
495
495
|
continue;
|
|
496
496
|
}
|
|
497
|
-
|
|
498
|
-
} catch (
|
|
499
|
-
|
|
497
|
+
a = n.call(o, e);
|
|
498
|
+
} catch (v) {
|
|
499
|
+
a = [6, v], r = 0;
|
|
500
500
|
} finally {
|
|
501
|
-
|
|
501
|
+
s = t = 0;
|
|
502
502
|
}
|
|
503
|
-
if (
|
|
504
|
-
return { value:
|
|
503
|
+
if (a[0] & 5) throw a[1];
|
|
504
|
+
return { value: a[0] ? a[1] : void 0, done: !0 };
|
|
505
505
|
}
|
|
506
506
|
};
|
|
507
507
|
Object.defineProperty(h, "__esModule", { value: !0 }), h.useUnityContext = void 0;
|
|
508
|
-
var
|
|
509
|
-
var n = (0, b.useNullableState)(), e = n[0],
|
|
508
|
+
var i = g, y = te(), f = we(), b = he(), m = function(o) {
|
|
509
|
+
var n = (0, b.useNullableState)(), e = n[0], s = n[1], r = (0, i.useState)(0), t = r[0], d = r[1], U = (0, i.useState)(!1), u = U[0], a = U[1], v = (0, b.useNullableState)(), I = v[0], ne = v[1], R = (0, f.useEventSystem)(), re = (0, i.useRef)({
|
|
510
510
|
setLoadingProgression: d,
|
|
511
|
-
setInitialisationError:
|
|
512
|
-
setUnityInstance:
|
|
513
|
-
setIsLoaded:
|
|
511
|
+
setInitialisationError: ne,
|
|
512
|
+
setUnityInstance: s,
|
|
513
|
+
setIsLoaded: a,
|
|
514
514
|
unityConfig: o
|
|
515
|
-
}),
|
|
515
|
+
}), ae = (0, i.useCallback)(
|
|
516
516
|
/**
|
|
517
517
|
* @param enabled Defines whether Unity should be in fullscreen.
|
|
518
518
|
*/
|
|
@@ -524,41 +524,41 @@ function he() {
|
|
|
524
524
|
e.SetFullscreen(_ === !0 ? 1 : 0);
|
|
525
525
|
},
|
|
526
526
|
[e]
|
|
527
|
-
),
|
|
527
|
+
), ie = (0, i.useCallback)(function() {
|
|
528
528
|
if (e === null || typeof e.Module.canvas > "u") {
|
|
529
529
|
console.warn(y.errorMessages.requestPointerLockNoUnityInstanceOrCanvas);
|
|
530
530
|
return;
|
|
531
531
|
}
|
|
532
532
|
return e.Module.canvas.requestPointerLock();
|
|
533
|
-
}, [e]),
|
|
533
|
+
}, [e]), se = (0, i.useCallback)(
|
|
534
534
|
/**
|
|
535
535
|
* @param gameObjectName the name of the game object in your Unity scene.
|
|
536
536
|
* @param methodName the name of the public method on the game object.
|
|
537
537
|
* @param parameter an optional parameter to pass along to the method.
|
|
538
538
|
*/
|
|
539
|
-
function(_,
|
|
539
|
+
function(_, C, le) {
|
|
540
540
|
if (e === null) {
|
|
541
541
|
console.warn(y.errorMessages.sendMessageNoUnityInstance);
|
|
542
542
|
return;
|
|
543
543
|
}
|
|
544
|
-
e.SendMessage(_,
|
|
544
|
+
e.SendMessage(_, C, le);
|
|
545
545
|
},
|
|
546
546
|
[e]
|
|
547
|
-
),
|
|
547
|
+
), ue = (0, i.useCallback)(
|
|
548
548
|
/**
|
|
549
549
|
* @param dataType Defines the type of screenshot to take.
|
|
550
550
|
* @param quality Defines the quality of the screenshot.
|
|
551
551
|
* @returns A base 64 encoded string of the screenshot.
|
|
552
552
|
*/
|
|
553
|
-
function(_,
|
|
553
|
+
function(_, C) {
|
|
554
554
|
if (e === null || typeof e.Module.canvas > "u") {
|
|
555
555
|
console.warn(y.errorMessages.screenshotNoUnityInstanceOrCanvas);
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
|
-
return e.Module.canvas.toDataURL(_,
|
|
558
|
+
return e.Module.canvas.toDataURL(_, C);
|
|
559
559
|
},
|
|
560
560
|
[e]
|
|
561
|
-
),
|
|
561
|
+
), O = (0, i.useCallback)(
|
|
562
562
|
/**
|
|
563
563
|
* @returns A promise that resolves when the UnityInstance has been unloaded.
|
|
564
564
|
*/
|
|
@@ -566,19 +566,19 @@ function he() {
|
|
|
566
566
|
return e === null ? (console.warn(y.errorMessages.quitNoUnityInstance), Promise.reject()) : e.Quit();
|
|
567
567
|
},
|
|
568
568
|
[e]
|
|
569
|
-
),
|
|
569
|
+
), oe = (0, i.useCallback)(
|
|
570
570
|
/**
|
|
571
571
|
* @returns A promise that resolves when the UnityInstance has been unloaded.
|
|
572
572
|
*/
|
|
573
573
|
function() {
|
|
574
574
|
return l(void 0, void 0, void 0, function() {
|
|
575
575
|
var _;
|
|
576
|
-
return c(this, function(
|
|
577
|
-
switch (
|
|
576
|
+
return c(this, function(C) {
|
|
577
|
+
switch (C.label) {
|
|
578
578
|
case 0:
|
|
579
|
-
return e === null || typeof e.Module.canvas > "u" ? (console.warn(y.errorMessages.genericNoUnityInstance), [2, Promise.reject()]) : (_ = e.Module.canvas, document.body.appendChild(_), _.style.display = "none", [4,
|
|
579
|
+
return e === null || typeof e.Module.canvas > "u" ? (console.warn(y.errorMessages.genericNoUnityInstance), [2, Promise.reject()]) : (_ = e.Module.canvas, document.body.appendChild(_), _.style.display = "none", [4, O()]);
|
|
580
580
|
case 1:
|
|
581
|
-
return
|
|
581
|
+
return C.sent(), _.remove(), [
|
|
582
582
|
2
|
|
583
583
|
/*return*/
|
|
584
584
|
];
|
|
@@ -588,88 +588,96 @@ function he() {
|
|
|
588
588
|
},
|
|
589
589
|
[e]
|
|
590
590
|
);
|
|
591
|
-
return (0,
|
|
592
|
-
|
|
591
|
+
return (0, i.useEffect)(function() {
|
|
592
|
+
a(t === 1);
|
|
593
593
|
}, [t]), {
|
|
594
|
-
unityProvider:
|
|
594
|
+
unityProvider: re.current,
|
|
595
595
|
loadingProgression: t,
|
|
596
|
-
initialisationError:
|
|
597
|
-
isLoaded:
|
|
596
|
+
initialisationError: I,
|
|
597
|
+
isLoaded: u,
|
|
598
598
|
UNSAFE__unityInstance: e,
|
|
599
|
-
requestFullscreen:
|
|
600
|
-
requestPointerLock:
|
|
601
|
-
sendMessage:
|
|
602
|
-
takeScreenshot:
|
|
603
|
-
unload:
|
|
604
|
-
UNSAFE__detachAndUnloadImmediate:
|
|
605
|
-
addEventListener:
|
|
606
|
-
removeEventListener:
|
|
599
|
+
requestFullscreen: ae,
|
|
600
|
+
requestPointerLock: ie,
|
|
601
|
+
sendMessage: se,
|
|
602
|
+
takeScreenshot: ue,
|
|
603
|
+
unload: O,
|
|
604
|
+
UNSAFE__detachAndUnloadImmediate: oe,
|
|
605
|
+
addEventListener: R.addEventListener,
|
|
606
|
+
removeEventListener: R.removeEventListener
|
|
607
607
|
};
|
|
608
608
|
};
|
|
609
609
|
return h.useUnityContext = m, h;
|
|
610
610
|
}
|
|
611
|
-
var
|
|
612
|
-
function
|
|
613
|
-
return
|
|
611
|
+
var Y;
|
|
612
|
+
function Ie() {
|
|
613
|
+
return Y || (Y = 1, function(l) {
|
|
614
614
|
Object.defineProperty(l, "__esModule", { value: !0 }), l.useUnityContext = l.Unity = void 0;
|
|
615
|
-
var c =
|
|
615
|
+
var c = _e();
|
|
616
616
|
Object.defineProperty(l, "Unity", { enumerable: !0, get: function() {
|
|
617
617
|
return c.Unity;
|
|
618
618
|
} });
|
|
619
|
-
var
|
|
619
|
+
var i = ge();
|
|
620
620
|
Object.defineProperty(l, "useUnityContext", { enumerable: !0, get: function() {
|
|
621
|
-
return
|
|
621
|
+
return i.useUnityContext;
|
|
622
622
|
} });
|
|
623
623
|
}(j)), j;
|
|
624
624
|
}
|
|
625
|
-
var
|
|
626
|
-
const
|
|
627
|
-
({ className: l, gameLink: c, loadingComponent:
|
|
625
|
+
var Z = Ie();
|
|
626
|
+
const Se = de.forwardRef(
|
|
627
|
+
({ className: l, gameLink: c, loadingComponent: i, registerEvents: y, onEventReceived: f }, b) => {
|
|
628
628
|
const {
|
|
629
629
|
unityProvider: m,
|
|
630
630
|
isLoaded: o,
|
|
631
631
|
loadingProgression: n,
|
|
632
632
|
UNSAFE__unityInstance: e,
|
|
633
|
-
addEventListener:
|
|
634
|
-
removeEventListener: r
|
|
635
|
-
|
|
633
|
+
addEventListener: s,
|
|
634
|
+
removeEventListener: r,
|
|
635
|
+
unload: t
|
|
636
|
+
} = Z.useUnityContext({
|
|
636
637
|
loaderUrl: `${c}/Build/Build.loader.js`,
|
|
637
638
|
dataUrl: `${c}/Build/Build.data.unityweb`,
|
|
638
639
|
frameworkUrl: `${c}/Build/Build.framework.js.unityweb`,
|
|
639
640
|
codeUrl: `${c}/Build/Build.wasm.unityweb`
|
|
640
|
-
}),
|
|
641
|
-
return
|
|
642
|
-
|
|
641
|
+
}), d = B(null), U = B([]);
|
|
642
|
+
return ve(
|
|
643
|
+
b,
|
|
644
|
+
() => ({
|
|
645
|
+
unload: t,
|
|
646
|
+
canvas: d.current
|
|
647
|
+
}),
|
|
648
|
+
[t]
|
|
649
|
+
), F(() => {
|
|
650
|
+
if (!(y && f))
|
|
643
651
|
return () => {
|
|
644
652
|
};
|
|
645
|
-
const
|
|
646
|
-
for (const
|
|
647
|
-
if (!
|
|
648
|
-
const
|
|
649
|
-
|
|
653
|
+
const u = [];
|
|
654
|
+
for (const a of y)
|
|
655
|
+
if (!U.current.some((v) => v.key === a)) {
|
|
656
|
+
const v = (I) => {
|
|
657
|
+
f == null || f(a, I);
|
|
650
658
|
};
|
|
651
|
-
|
|
659
|
+
s(a, v), u.push({ key: a, event: v });
|
|
652
660
|
}
|
|
653
|
-
return
|
|
654
|
-
for (const { key:
|
|
655
|
-
r(
|
|
656
|
-
|
|
661
|
+
return U.current = [...U.current, ...u], () => {
|
|
662
|
+
for (const { key: a, event: v } of U.current)
|
|
663
|
+
r(a, v);
|
|
664
|
+
U.current = [];
|
|
657
665
|
};
|
|
658
|
-
}, [y,
|
|
666
|
+
}, [y, s, r, f]), F(() => {
|
|
659
667
|
window && e && (window.unityInstance = e);
|
|
660
|
-
}, [e]), /* @__PURE__ */ P(
|
|
661
|
-
!o && (
|
|
668
|
+
}, [e]), /* @__PURE__ */ P(ce, { children: [
|
|
669
|
+
!o && (i ? /* @__PURE__ */ $(i, { progress: n }) : /* @__PURE__ */ P("div", { className: "h-full w-full items-center justify-center text-center", children: [
|
|
662
670
|
"Loading $",
|
|
663
671
|
n * 100,
|
|
664
672
|
"%"
|
|
665
673
|
] })),
|
|
666
674
|
/* @__PURE__ */ $(
|
|
667
|
-
|
|
675
|
+
Z.Unity,
|
|
668
676
|
{
|
|
669
|
-
ref:
|
|
677
|
+
ref: d,
|
|
670
678
|
id: "unity-canvas",
|
|
671
679
|
unityProvider: m,
|
|
672
|
-
className:
|
|
680
|
+
className: fe(l, !o && "hidden"),
|
|
673
681
|
devicePixelRatio: (window == null ? void 0 : window.devicePixelRatio) || 1
|
|
674
682
|
}
|
|
675
683
|
)
|
|
@@ -677,5 +685,5 @@ const Le = ce.forwardRef(
|
|
|
677
685
|
}
|
|
678
686
|
);
|
|
679
687
|
export {
|
|
680
|
-
|
|
688
|
+
Se as UnityGame
|
|
681
689
|
};
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED