promogame-player 0.0.2

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.
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ export interface UnityGameProps extends React.RefAttributes<HTMLCanvasElement> {
3
+ gameLink?: string;
4
+ loadingComponent?: React.ComponentType<{
5
+ progress: number;
6
+ }>;
7
+ className?: string;
8
+ }
9
+ export declare const UnityGame: React.ForwardRefExoticComponent<Omit<UnityGameProps, "ref"> & React.RefAttributes<HTMLCanvasElement>>;
@@ -0,0 +1,657 @@
1
+ import { jsxs as P, Fragment as oe, jsx as $ } from "react/jsx-runtime";
2
+ import * as le from "react";
3
+ import g, { useEffect as ce } from "react";
4
+ import { cn as de } from "../../utils.js";
5
+ var j = {}, L = {}, S = {}, B;
6
+ function ve() {
7
+ if (B) return S;
8
+ B = 1, Object.defineProperty(S, "__esModule", { value: !0 }), S.useUnityCanvasId = void 0;
9
+ var l = g, c = 0, a = "react-unity-webgl-canvas", v = function(f) {
10
+ if (f.id !== void 0)
11
+ return f.id;
12
+ var m = (0, l.useMemo)(function() {
13
+ return [a, ++c].join("-");
14
+ }, []);
15
+ return m;
16
+ };
17
+ return S.useUnityCanvasId = v, S;
18
+ }
19
+ var w = {}, p = {}, F;
20
+ function Y() {
21
+ if (F) return p;
22
+ F = 1, Object.defineProperty(p, "__esModule", { value: !0 }), p.UnityLoaderStatus = void 0;
23
+ var l;
24
+ return function(c) {
25
+ c.Idle = "Idle", c.Loading = "Loading", c.Loaded = "Loaded", c.Error = "Error";
26
+ }(l || (p.UnityLoaderStatus = l = {})), p;
27
+ }
28
+ var q = {}, G;
29
+ function R() {
30
+ return G || (G = 1, Object.defineProperty(q, "__esModule", { value: !0 }), q.isBrowserEnvironment = void 0, q.isBrowserEnvironment = typeof window < "u" && typeof document < "u"), q;
31
+ }
32
+ var T;
33
+ function fe() {
34
+ if (T) return w;
35
+ T = 1;
36
+ var l = w && w.__awaiter || function(U, u, n, e) {
37
+ function s(r) {
38
+ return r instanceof n ? r : new n(function(t) {
39
+ t(r);
40
+ });
41
+ }
42
+ return new (n || (n = Promise))(function(r, t) {
43
+ function d(i) {
44
+ try {
45
+ o(e.next(i));
46
+ } catch (y) {
47
+ t(y);
48
+ }
49
+ }
50
+ function b(i) {
51
+ try {
52
+ o(e.throw(i));
53
+ } catch (y) {
54
+ t(y);
55
+ }
56
+ }
57
+ function o(i) {
58
+ i.done ? r(i.value) : s(i.value).then(d, b);
59
+ }
60
+ o((e = e.apply(U, u || [])).next());
61
+ });
62
+ }, c = w && w.__generator || function(U, u) {
63
+ var n = { label: 0, sent: function() {
64
+ if (r[0] & 1) throw r[1];
65
+ return r[1];
66
+ }, trys: [], ops: [] }, e, s, r, t = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
67
+ return t.next = d(0), t.throw = d(1), t.return = d(2), typeof Symbol == "function" && (t[Symbol.iterator] = function() {
68
+ return this;
69
+ }), t;
70
+ function d(o) {
71
+ return function(i) {
72
+ return b([o, i]);
73
+ };
74
+ }
75
+ function b(o) {
76
+ if (e) throw new TypeError("Generator is already executing.");
77
+ for (; t && (t = 0, o[0] && (n = 0)), n; ) try {
78
+ if (e = 1, s && (r = o[0] & 2 ? s.return : o[0] ? s.throw || ((r = s.return) && r.call(s), 0) : s.next) && !(r = r.call(s, o[1])).done) return r;
79
+ switch (s = 0, r && (o = [o[0] & 2, r.value]), o[0]) {
80
+ case 0:
81
+ case 1:
82
+ r = o;
83
+ break;
84
+ case 4:
85
+ return n.label++, { value: o[1], done: !1 };
86
+ case 5:
87
+ n.label++, s = o[1], o = [0];
88
+ continue;
89
+ case 7:
90
+ o = n.ops.pop(), n.trys.pop();
91
+ continue;
92
+ default:
93
+ if (r = n.trys, !(r = r.length > 0 && r[r.length - 1]) && (o[0] === 6 || o[0] === 2)) {
94
+ n = 0;
95
+ continue;
96
+ }
97
+ if (o[0] === 3 && (!r || o[1] > r[0] && o[1] < r[3])) {
98
+ n.label = o[1];
99
+ break;
100
+ }
101
+ if (o[0] === 6 && n.label < r[1]) {
102
+ n.label = r[1], r = o;
103
+ break;
104
+ }
105
+ if (r && n.label < r[2]) {
106
+ n.label = r[2], n.ops.push(o);
107
+ break;
108
+ }
109
+ r[2] && n.ops.pop(), n.trys.pop();
110
+ continue;
111
+ }
112
+ o = u.call(U, n);
113
+ } catch (i) {
114
+ o = [6, i], s = 0;
115
+ } finally {
116
+ e = r = 0;
117
+ }
118
+ if (o[0] & 5) throw o[1];
119
+ return { value: o[0] ? o[1] : void 0, done: !0 };
120
+ }
121
+ };
122
+ Object.defineProperty(w, "__esModule", { value: !0 }), w.useUnityInstance = void 0;
123
+ var a = g, v = Y(), f = R(), m = function(U, u, n, e) {
124
+ (0, a.useEffect)(function() {
125
+ (function() {
126
+ return l(void 0, void 0, void 0, function() {
127
+ var s, r;
128
+ return c(this, function(t) {
129
+ switch (t.label) {
130
+ case 0:
131
+ if (f.isBrowserEnvironment === !1)
132
+ return [
133
+ 2
134
+ /*return*/
135
+ ];
136
+ if (U !== v.UnityLoaderStatus.Loaded || u === null)
137
+ return e.setUnityInstance(null), e.setInitialisationError(null), [
138
+ 2
139
+ /*return*/
140
+ ];
141
+ t.label = 1;
142
+ case 1:
143
+ return t.trys.push([1, 3, , 4]), [4, window.createUnityInstance(u, n, e.setLoadingProgression)];
144
+ case 2:
145
+ return s = t.sent(), e.setUnityInstance(s), e.setInitialisationError(null), [3, 4];
146
+ case 3:
147
+ return r = t.sent(), e.setUnityInstance(null), e.setInitialisationError(r), [3, 4];
148
+ case 4:
149
+ return [
150
+ 2
151
+ /*return*/
152
+ ];
153
+ }
154
+ });
155
+ });
156
+ })();
157
+ }, [U, u, n, e]);
158
+ };
159
+ return w.useUnityInstance = m, w;
160
+ }
161
+ var M = {}, D;
162
+ function ye() {
163
+ if (D) return M;
164
+ D = 1, Object.defineProperty(M, "__esModule", { value: !0 }), M.useUnityArguments = void 0;
165
+ var l = g, c = function(a) {
166
+ return (0, l.useMemo)(function() {
167
+ return {
168
+ // Assigns the data URL, framework URL, and code URL to the Unity
169
+ // arguments object.
170
+ dataUrl: a.unityProvider.unityConfig.dataUrl,
171
+ frameworkUrl: a.unityProvider.unityConfig.frameworkUrl,
172
+ codeUrl: a.unityProvider.unityConfig.codeUrl,
173
+ // Assigns the optional streaming assets URL, memory URL, symbols URL,
174
+ // and worker URL to the Unity arguments object.
175
+ streamingAssetsUrl: a.unityProvider.unityConfig.streamingAssetsUrl,
176
+ memoryUrl: a.unityProvider.unityConfig.memoryUrl,
177
+ symbolsUrl: a.unityProvider.unityConfig.symbolsUrl,
178
+ workerUrl: a.unityProvider.unityConfig.workerUrl,
179
+ // Assigns the optional company name, product name, and product version to
180
+ // the Unity arguments object.
181
+ companyName: a.unityProvider.unityConfig.companyName,
182
+ productName: a.unityProvider.unityConfig.productName,
183
+ productVersion: a.unityProvider.unityConfig.productVersion,
184
+ // Assigns the webgl context attributes to the Unity arguments object.
185
+ // If the webgl context attributes are not defined via the Unity Props,
186
+ // the default value of an empty object will be used.
187
+ webglContextAttributes: a.unityProvider.unityConfig.webglContextAttributes || {},
188
+ // Assigns the cache control value to the Unity arguments object. If the
189
+ // cache control value is not defined via the Unity Props, the default
190
+ // value of always `must-revalidate` will be used.
191
+ cacheControl: a.unityProvider.unityConfig.cacheControl || function() {
192
+ return "must-revalidate";
193
+ },
194
+ // Assigns the device pixel ratio to the Unity arguments object. If the
195
+ // device pixel ratio is not defined via the Unity Props, the default
196
+ // value of `1` will be used.
197
+ devicePixelRatio: a.devicePixelRatio || 1,
198
+ // Assigns the auto sync persistent data path value to the Unity arguments
199
+ // object. If the auto sync persistent data path value is not defined via
200
+ // the Unity Props, the default value of `undefined` will be used.
201
+ autoSyncPersistentDataPath: a.autoSyncPersistentDataPath,
202
+ // Assigns the match WebGL to canvas size value to the Unity arguments
203
+ // object. If the match WebGL to canvas size value is not defined via the
204
+ // Unity Props, the default value of `true` will be used.
205
+ matchWebGLToCanvasSize: typeof a.matchWebGLToCanvasSize == "boolean" ? a.matchWebGLToCanvasSize : !0,
206
+ // Assigns the disabled canvas events to the Unity arguments object. If
207
+ // the disabled canvas events are not defined via the Unity Props, the
208
+ // default value of `contextmenu` and `dragstart` will be used.
209
+ disabledCanvasEvents: a.disabledCanvasEvents || [
210
+ "contextmenu",
211
+ "dragstart"
212
+ ],
213
+ // Assigns the print hook to the Unity arguments object. This hook will
214
+ // be called whenever the Unity instance prints a message.
215
+ print: (
216
+ /**
217
+ * Intercept print events in order to catch messages and send them to
218
+ * the unity context instead.
219
+ * @param message The message to be printed.
220
+ */
221
+ function(v) {
222
+ }
223
+ ),
224
+ // Assigns the print error hook to the Unity arguments object. This hook
225
+ // will be called whenever the Unity instance prints an error.
226
+ printErr: (
227
+ /**
228
+ * Intercept print error events in order to catch messages and send them
229
+ * to the unity context instead.
230
+ * @param error The error to be printed.
231
+ */
232
+ function(v) {
233
+ }
234
+ )
235
+ };
236
+ }, []);
237
+ };
238
+ return M.useUnityArguments = c, M;
239
+ }
240
+ var x = {}, z;
241
+ function Ue() {
242
+ if (z) return x;
243
+ z = 1, Object.defineProperty(x, "__esModule", { value: !0 }), x.useUnityLoader = void 0;
244
+ var l = g, c = R(), a = Y(), v = function(f) {
245
+ var m = (0, l.useState)(a.UnityLoaderStatus.Loading), U = m[0], u = m[1];
246
+ return (0, l.useEffect)(function() {
247
+ if (c.isBrowserEnvironment !== !1) {
248
+ if (f.loaderUrl === null) {
249
+ u(a.UnityLoaderStatus.Idle);
250
+ return;
251
+ }
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
+ return n == null ? void 0 : n.setAttribute("data-status", "loaded");
255
+ }), n.addEventListener("error", function() {
256
+ return n == null ? void 0 : n.setAttribute("data-status", "error");
257
+ })) : u(n.getAttribute("data-status") === "loaded" ? a.UnityLoaderStatus.Loaded : a.UnityLoaderStatus.Error);
258
+ var e = function(s) {
259
+ return u(s.type === "load" ? a.UnityLoaderStatus.Loaded : a.UnityLoaderStatus.Error);
260
+ };
261
+ return n.addEventListener("load", e), n.addEventListener("error", e), function() {
262
+ n !== null && (n.removeEventListener("load", e), n.removeEventListener("error", e), window.document.body.removeChild(n));
263
+ };
264
+ }
265
+ }, [f.loaderUrl]), U;
266
+ };
267
+ return x.useUnityLoader = v, x;
268
+ }
269
+ var V;
270
+ function me() {
271
+ if (V) return L;
272
+ V = 1, Object.defineProperty(L, "__esModule", { value: !0 }), L.Unity = void 0;
273
+ var l = g, c = g, a = ve(), v = fe(), f = ye(), m = Ue(), U = (0, c.forwardRef)(
274
+ /**
275
+ * @param unityProps The Unity props provided the the Unity component.
276
+ * @param forwardedRef The forwarded ref to the Unity component.
277
+ * @returns The Unity canvas renderer.
278
+ */
279
+ function(u, n) {
280
+ var e = (0, c.useRef)(null), s = (0, a.useUnityCanvasId)(u), r = (0, f.useUnityArguments)(u), t = (0, m.useUnityLoader)(u.unityProvider.unityConfig);
281
+ return (0, v.useUnityInstance)(t, e.current, r, u.unityProvider), (0, l.useImperativeHandle)(n, function() {
282
+ return e.current;
283
+ }), (0, l.createElement)("canvas", {
284
+ ref: e,
285
+ id: s,
286
+ style: u.style,
287
+ className: u.className,
288
+ tabIndex: u.tabIndex
289
+ });
290
+ }
291
+ );
292
+ return L.Unity = U, L;
293
+ }
294
+ var h = {}, N = {}, W;
295
+ function Z() {
296
+ if (W) return N;
297
+ W = 1, Object.defineProperty(N, "__esModule", { value: !0 }), N.errorMessages = void 0;
298
+ var l = {
299
+ /**
300
+ * A generic error message when the Unity Instance is not available.
301
+ */
302
+ genericNoUnityInstance: "No Unity Instance found.",
303
+ /**
304
+ * The error message for when no Unity Instance was found while trying to set
305
+ * the fullscreen mode.
306
+ */
307
+ requestFullscreenNoUnityInstance: "Unable to Set Fullscreen while Unity is not Instantiated.",
308
+ /**
309
+ * The error message for when no Unity Instance was found while trying to
310
+ * request the pointer lock.
311
+ */
312
+ requestPointerLockNoUnityInstanceOrCanvas: "Unable to Request Pointer Lock while Unity is not Instantiated or the Canvas is not found.",
313
+ /**
314
+ * The error message for when no Unity Instance was found while trying to send
315
+ * a message.
316
+ */
317
+ sendMessageNoUnityInstance: "Unable to Send Message while Unity is not Instantiated.",
318
+ /**
319
+ * The error message for when no Unity Instance was found while trying to quit
320
+ * the Unity Instance.
321
+ */
322
+ quitNoUnityInstance: "Unable to Quit Unity while Unity is not Instantiated.",
323
+ /**
324
+ * The error message for when no Unity Instance or Canvas was found while
325
+ * trying to take a screenshot.
326
+ */
327
+ screenshotNoUnityInstanceOrCanvas: "Unable to Take Screenshot while Unity is not Instantiated or Canvas is not available.",
328
+ /**
329
+ * The error message for when no event listener was found in the event
330
+ * system.
331
+ */
332
+ noEventListener: "Unable to find Event Listener in Event System for Event"
333
+ };
334
+ return N.errorMessages = l, N;
335
+ }
336
+ var E = {}, Q;
337
+ function be() {
338
+ if (Q) return E;
339
+ Q = 1;
340
+ var l = E && E.__spreadArray || function(u, 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
+ return u.concat(t || Array.prototype.slice.call(n));
344
+ };
345
+ Object.defineProperty(E, "__esModule", { value: !0 }), E.useEventSystem = void 0;
346
+ var c = g, a = Z(), v = R(), f = [], m = function(u) {
347
+ for (var n = [], e = 1; e < arguments.length; e++)
348
+ n[e - 1] = arguments[e];
349
+ var s = void 0;
350
+ return f.forEach(function(r) {
351
+ s = r.apply(void 0, l([u], n, !1));
352
+ }), s;
353
+ };
354
+ v.isBrowserEnvironment === !0 && (window.dispatchReactUnityEvent = m);
355
+ var U = function() {
356
+ var u = (0, c.useRef)([]), n = (0, c.useCallback)(
357
+ /**
358
+ * @param eventName The name of the event to listen to.
359
+ * @param callback The callback to invoke when the event is fired.
360
+ */
361
+ function(r, t) {
362
+ u.current = l(l([], u.current, !0), [
363
+ { eventName: r, callback: t }
364
+ ], !1);
365
+ },
366
+ [u]
367
+ ), e = (0, c.useCallback)(
368
+ /**
369
+ * @param eventName The name of the event to remove.
370
+ * @param callback The callback to remove.
371
+ */
372
+ function(r, t) {
373
+ u.current = u.current.filter(function(d) {
374
+ return d.eventName !== r && d.callback !== t;
375
+ });
376
+ },
377
+ [u]
378
+ ), s = (0, c.useCallback)(
379
+ /**
380
+ * @param eventName The name of the event to dispatch.
381
+ * @param parameters The parameters to pass to the event listener.
382
+ */
383
+ function(r) {
384
+ for (var t = [], d = 1; d < arguments.length; d++)
385
+ t[d - 1] = arguments[d];
386
+ var b = u.current.find(function(o) {
387
+ return o.eventName === r;
388
+ });
389
+ if (typeof b > "u") {
390
+ console.warn(a.errorMessages.noEventListener, { eventName: r });
391
+ return;
392
+ }
393
+ return b.callback.apply(b, t);
394
+ },
395
+ [u]
396
+ );
397
+ return (0, c.useEffect)(function() {
398
+ return f.push(s), function() {
399
+ f.splice(f.indexOf(s), 1);
400
+ };
401
+ }, [s]), {
402
+ addEventListener: n,
403
+ removeEventListener: e
404
+ };
405
+ };
406
+ return E.useEventSystem = U, E;
407
+ }
408
+ var k = {}, H;
409
+ function _e() {
410
+ if (H) return k;
411
+ H = 1, Object.defineProperty(k, "__esModule", { value: !0 }), k.useNullableState = void 0;
412
+ var l = g, c = function(a) {
413
+ return (0, l.useState)(a || null);
414
+ };
415
+ return k.useNullableState = c, k;
416
+ }
417
+ var J;
418
+ function we() {
419
+ if (J) return h;
420
+ J = 1;
421
+ var l = h && h.__awaiter || function(u, n, e, s) {
422
+ function r(t) {
423
+ return t instanceof e ? t : new e(function(d) {
424
+ d(t);
425
+ });
426
+ }
427
+ return new (e || (e = Promise))(function(t, d) {
428
+ function b(y) {
429
+ try {
430
+ i(s.next(y));
431
+ } catch (C) {
432
+ d(C);
433
+ }
434
+ }
435
+ function o(y) {
436
+ try {
437
+ i(s.throw(y));
438
+ } catch (C) {
439
+ d(C);
440
+ }
441
+ }
442
+ function i(y) {
443
+ y.done ? t(y.value) : r(y.value).then(b, o);
444
+ }
445
+ i((s = s.apply(u, n || [])).next());
446
+ });
447
+ }, c = h && h.__generator || function(u, n) {
448
+ var e = { label: 0, sent: function() {
449
+ if (t[0] & 1) throw t[1];
450
+ return t[1];
451
+ }, trys: [], ops: [] }, s, r, t, d = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
452
+ return d.next = b(0), d.throw = b(1), d.return = b(2), typeof Symbol == "function" && (d[Symbol.iterator] = function() {
453
+ return this;
454
+ }), d;
455
+ function b(i) {
456
+ return function(y) {
457
+ return o([i, y]);
458
+ };
459
+ }
460
+ function o(i) {
461
+ if (s) throw new TypeError("Generator is already executing.");
462
+ for (; d && (d = 0, i[0] && (e = 0)), e; ) try {
463
+ if (s = 1, r && (t = i[0] & 2 ? r.return : i[0] ? r.throw || ((t = r.return) && t.call(r), 0) : r.next) && !(t = t.call(r, i[1])).done) return t;
464
+ switch (r = 0, t && (i = [i[0] & 2, t.value]), i[0]) {
465
+ case 0:
466
+ case 1:
467
+ t = i;
468
+ break;
469
+ case 4:
470
+ return e.label++, { value: i[1], done: !1 };
471
+ case 5:
472
+ e.label++, r = i[1], i = [0];
473
+ continue;
474
+ case 7:
475
+ i = e.ops.pop(), e.trys.pop();
476
+ continue;
477
+ default:
478
+ if (t = e.trys, !(t = t.length > 0 && t[t.length - 1]) && (i[0] === 6 || i[0] === 2)) {
479
+ e = 0;
480
+ continue;
481
+ }
482
+ if (i[0] === 3 && (!t || i[1] > t[0] && i[1] < t[3])) {
483
+ e.label = i[1];
484
+ break;
485
+ }
486
+ if (i[0] === 6 && e.label < t[1]) {
487
+ e.label = t[1], t = i;
488
+ break;
489
+ }
490
+ if (t && e.label < t[2]) {
491
+ e.label = t[2], e.ops.push(i);
492
+ break;
493
+ }
494
+ t[2] && e.ops.pop(), e.trys.pop();
495
+ continue;
496
+ }
497
+ i = n.call(u, e);
498
+ } catch (y) {
499
+ i = [6, y], r = 0;
500
+ } finally {
501
+ s = t = 0;
502
+ }
503
+ if (i[0] & 5) throw i[1];
504
+ return { value: i[0] ? i[1] : void 0, done: !0 };
505
+ }
506
+ };
507
+ Object.defineProperty(h, "__esModule", { value: !0 }), h.useUnityContext = void 0;
508
+ var a = g, v = Z(), f = be(), m = _e(), U = function(u) {
509
+ var n = (0, m.useNullableState)(), e = n[0], s = n[1], r = (0, a.useState)(0), t = r[0], d = r[1], b = (0, a.useState)(!1), o = b[0], i = b[1], y = (0, m.useNullableState)(), C = y[0], ee = y[1], A = (0, f.useEventSystem)(), te = (0, a.useRef)({
510
+ setLoadingProgression: d,
511
+ setInitialisationError: ee,
512
+ setUnityInstance: s,
513
+ setIsLoaded: i,
514
+ unityConfig: u
515
+ }), ne = (0, a.useCallback)(
516
+ /**
517
+ * @param enabled Defines whether Unity should be in fullscreen.
518
+ */
519
+ function(_) {
520
+ if (e === null) {
521
+ console.warn(v.errorMessages.requestFullscreenNoUnityInstance);
522
+ return;
523
+ }
524
+ e.SetFullscreen(_ === !0 ? 1 : 0);
525
+ },
526
+ [e]
527
+ ), re = (0, a.useCallback)(function() {
528
+ if (e === null || typeof e.Module.canvas > "u") {
529
+ console.warn(v.errorMessages.requestPointerLockNoUnityInstanceOrCanvas);
530
+ return;
531
+ }
532
+ return e.Module.canvas.requestPointerLock();
533
+ }, [e]), ae = (0, a.useCallback)(
534
+ /**
535
+ * @param gameObjectName the name of the game object in your Unity scene.
536
+ * @param methodName the name of the public method on the game object.
537
+ * @param parameter an optional parameter to pass along to the method.
538
+ */
539
+ function(_, I, ue) {
540
+ if (e === null) {
541
+ console.warn(v.errorMessages.sendMessageNoUnityInstance);
542
+ return;
543
+ }
544
+ e.SendMessage(_, I, ue);
545
+ },
546
+ [e]
547
+ ), ie = (0, a.useCallback)(
548
+ /**
549
+ * @param dataType Defines the type of screenshot to take.
550
+ * @param quality Defines the quality of the screenshot.
551
+ * @returns A base 64 encoded string of the screenshot.
552
+ */
553
+ function(_, I) {
554
+ if (e === null || typeof e.Module.canvas > "u") {
555
+ console.warn(v.errorMessages.screenshotNoUnityInstanceOrCanvas);
556
+ return;
557
+ }
558
+ return e.Module.canvas.toDataURL(_, I);
559
+ },
560
+ [e]
561
+ ), O = (0, a.useCallback)(
562
+ /**
563
+ * @returns A promise that resolves when the UnityInstance has been unloaded.
564
+ */
565
+ function() {
566
+ return e === null ? (console.warn(v.errorMessages.quitNoUnityInstance), Promise.reject()) : e.Quit();
567
+ },
568
+ [e]
569
+ ), se = (0, a.useCallback)(
570
+ /**
571
+ * @returns A promise that resolves when the UnityInstance has been unloaded.
572
+ */
573
+ function() {
574
+ return l(void 0, void 0, void 0, function() {
575
+ var _;
576
+ return c(this, function(I) {
577
+ switch (I.label) {
578
+ case 0:
579
+ return e === null || typeof e.Module.canvas > "u" ? (console.warn(v.errorMessages.genericNoUnityInstance), [2, Promise.reject()]) : (_ = e.Module.canvas, document.body.appendChild(_), _.style.display = "none", [4, O()]);
580
+ case 1:
581
+ return I.sent(), _.remove(), [
582
+ 2
583
+ /*return*/
584
+ ];
585
+ }
586
+ });
587
+ });
588
+ },
589
+ [e]
590
+ );
591
+ return (0, a.useEffect)(function() {
592
+ i(t === 1);
593
+ }, [t]), {
594
+ unityProvider: te.current,
595
+ loadingProgression: t,
596
+ initialisationError: C,
597
+ isLoaded: o,
598
+ UNSAFE__unityInstance: e,
599
+ requestFullscreen: ne,
600
+ requestPointerLock: re,
601
+ sendMessage: ae,
602
+ takeScreenshot: ie,
603
+ unload: O,
604
+ UNSAFE__detachAndUnloadImmediate: se,
605
+ addEventListener: A.addEventListener,
606
+ removeEventListener: A.removeEventListener
607
+ };
608
+ };
609
+ return h.useUnityContext = U, h;
610
+ }
611
+ var K;
612
+ function he() {
613
+ return K || (K = 1, function(l) {
614
+ Object.defineProperty(l, "__esModule", { value: !0 }), l.useUnityContext = l.Unity = void 0;
615
+ var c = me();
616
+ Object.defineProperty(l, "Unity", { enumerable: !0, get: function() {
617
+ return c.Unity;
618
+ } });
619
+ var a = we();
620
+ Object.defineProperty(l, "useUnityContext", { enumerable: !0, get: function() {
621
+ return a.useUnityContext;
622
+ } });
623
+ }(j)), j;
624
+ }
625
+ var X = he();
626
+ const Ce = le.forwardRef(
627
+ ({ className: l, gameLink: c, loadingComponent: a }, v) => {
628
+ const { unityProvider: f, isLoaded: m, loadingProgression: U, UNSAFE__unityInstance: u } = X.useUnityContext({
629
+ loaderUrl: `${c}/Build/Build.loader.js`,
630
+ dataUrl: `${c}/Build/Build.data.unityweb`,
631
+ frameworkUrl: `${c}/Build/Build.framework.js.unityweb`,
632
+ codeUrl: `${c}/Build/Build.wasm.unityweb`
633
+ });
634
+ return ce(() => {
635
+ window && u && (window.unityInstance = u);
636
+ }, [u]), /* @__PURE__ */ P(oe, { children: [
637
+ !m && (a ? /* @__PURE__ */ $(a, { progress: U }) : /* @__PURE__ */ P("div", { className: "h-full w-full items-center justify-center text-center", children: [
638
+ "Loading $",
639
+ U * 100,
640
+ "%"
641
+ ] })),
642
+ /* @__PURE__ */ $(
643
+ X.Unity,
644
+ {
645
+ ref: v,
646
+ id: "unity-canvas",
647
+ unityProvider: f,
648
+ className: de(l, !m && "hidden"),
649
+ devicePixelRatio: (window == null ? void 0 : window.devicePixelRatio) || 1
650
+ }
651
+ )
652
+ ] });
653
+ }
654
+ );
655
+ export {
656
+ Ce as UnityGame
657
+ };
@@ -0,0 +1,19 @@
1
+ import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { Incremental } from './graphql';
3
+ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<infer TType, any> ? [TType] extends [{
4
+ ' $fragmentName'?: infer TKey;
5
+ }] ? TKey extends string ? {
6
+ ' $fragmentRefs'?: {
7
+ [key in TKey]: TType;
8
+ };
9
+ } : never : never : never;
10
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>): TType;
11
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | undefined): TType | undefined;
12
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null): TType | null;
13
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined): TType | null | undefined;
14
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>>): Array<TType>;
15
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): Array<TType> | null | undefined;
16
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>): ReadonlyArray<TType>;
17
+ export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): ReadonlyArray<TType> | null | undefined;
18
+ export declare function makeFragmentData<F extends DocumentTypeDecoration<any, any>, FT extends ResultOf<F>>(data: FT, _fragment: F): FragmentType<F>;
19
+ export declare function isFragmentReady<TQuery, TFrag>(queryNode: DocumentTypeDecoration<TQuery, any>, fragmentNode: TypedDocumentNode<TFrag>, data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined): data is FragmentType<typeof fragmentNode>;