@air-jam/sdk 0.1.2 → 0.1.4
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/index.cjs +1631 -1770
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -41
- package/dist/index.d.ts +6 -41
- package/dist/index.js +1633 -1769
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
- package/src/components/controller-shell.tsx +94 -69
- package/src/components/{air-jam-overlay.tsx → host-shell.tsx} +57 -50
- package/src/components/player-avatar.tsx +0 -1
- package/src/context/air-jam-context.tsx +21 -1
- package/src/context/socket-manager.ts +0 -1
- package/src/index.ts +1 -3
- package/src/components/air-jam-debug.tsx +0 -77
- package/src/components/debug-state-dialog.tsx +0 -83
package/dist/index.cjs
CHANGED
|
@@ -7,16 +7,15 @@ var socket_ioClient = require('socket.io-client');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var howler = require('howler');
|
|
9
9
|
var lucideReact = require('lucide-react');
|
|
10
|
-
var
|
|
11
|
-
var classVarianceAuthority = require('class-variance-authority');
|
|
10
|
+
var zod = require('zod');
|
|
12
11
|
var clsx = require('clsx');
|
|
13
12
|
var tailwindMerge = require('tailwind-merge');
|
|
14
|
-
var
|
|
13
|
+
var html5Qrcode = require('html5-qrcode');
|
|
14
|
+
var reactSlot = require('@radix-ui/react-slot');
|
|
15
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
15
16
|
var QRCode = require('qrcode');
|
|
16
|
-
var zod = require('zod');
|
|
17
17
|
var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
18
18
|
var SliderPrimitive = require('@radix-ui/react-slider');
|
|
19
|
-
var html5Qrcode = require('html5-qrcode');
|
|
20
19
|
|
|
21
20
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
22
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -40,7 +39,6 @@ function _interopNamespace(e) {
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
43
|
-
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
44
42
|
var QRCode__default = /*#__PURE__*/_interopDefault(QRCode);
|
|
45
43
|
var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
46
44
|
var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
|
|
@@ -248,7 +246,6 @@ var SocketManager = class {
|
|
|
248
246
|
}
|
|
249
247
|
const socket = socket_ioClient.io(this.serverUrl, {
|
|
250
248
|
autoConnect: false,
|
|
251
|
-
transports: ["websocket"],
|
|
252
249
|
query: { role }
|
|
253
250
|
});
|
|
254
251
|
this.sockets[role] = socket;
|
|
@@ -335,6 +332,17 @@ var getEnvApiKey = () => {
|
|
|
335
332
|
}
|
|
336
333
|
return void 0;
|
|
337
334
|
};
|
|
335
|
+
var getEnvPublicHost = () => {
|
|
336
|
+
const viteEnv = getViteEnv();
|
|
337
|
+
if (viteEnv?.VITE_AIR_JAM_PUBLIC_HOST) {
|
|
338
|
+
return viteEnv.VITE_AIR_JAM_PUBLIC_HOST;
|
|
339
|
+
}
|
|
340
|
+
if (typeof process !== "undefined" && process.env) {
|
|
341
|
+
const nextHost = process.env.NEXT_PUBLIC_AIR_JAM_PUBLIC_HOST;
|
|
342
|
+
if (nextHost) return nextHost;
|
|
343
|
+
}
|
|
344
|
+
return void 0;
|
|
345
|
+
};
|
|
338
346
|
var AirJamProvider = ({
|
|
339
347
|
children,
|
|
340
348
|
serverUrl,
|
|
@@ -348,7 +356,7 @@ var AirJamProvider = ({
|
|
|
348
356
|
serverUrl: serverUrl ?? getEnvServerUrl(),
|
|
349
357
|
apiKey: apiKey ?? getEnvApiKey(),
|
|
350
358
|
maxPlayers,
|
|
351
|
-
publicHost
|
|
359
|
+
publicHost: publicHost ?? getEnvPublicHost()
|
|
352
360
|
}),
|
|
353
361
|
[serverUrl, apiKey, maxPlayers, publicHost]
|
|
354
362
|
);
|
|
@@ -821,213 +829,85 @@ var useAudioManager = (manifest) => {
|
|
|
821
829
|
}
|
|
822
830
|
return managerRef.current;
|
|
823
831
|
};
|
|
824
|
-
var
|
|
825
|
-
|
|
826
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
827
|
-
{
|
|
828
|
-
variants: {
|
|
829
|
-
variant: {
|
|
830
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
831
|
-
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
832
|
-
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
833
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
834
|
-
ghost: "text-foreground hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
835
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
836
|
-
},
|
|
837
|
-
size: {
|
|
838
|
-
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
839
|
-
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
840
|
-
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
841
|
-
icon: "size-9",
|
|
842
|
-
"icon-sm": "size-8",
|
|
843
|
-
"icon-lg": "size-10"
|
|
844
|
-
}
|
|
845
|
-
},
|
|
846
|
-
defaultVariants: {
|
|
847
|
-
variant: "default",
|
|
848
|
-
size: "default"
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
);
|
|
852
|
-
function Button({
|
|
853
|
-
className,
|
|
854
|
-
variant,
|
|
855
|
-
size,
|
|
856
|
-
asChild = false,
|
|
857
|
-
...props
|
|
858
|
-
}) {
|
|
859
|
-
const Comp = asChild ? reactSlot.Slot : "button";
|
|
860
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
861
|
-
Comp,
|
|
862
|
-
{
|
|
863
|
-
"data-slot": "button",
|
|
864
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
865
|
-
...props
|
|
866
|
-
}
|
|
867
|
-
);
|
|
868
|
-
}
|
|
869
|
-
var Dialog = DialogPrimitive__namespace.Root;
|
|
870
|
-
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
871
|
-
var DialogOverlay = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
872
|
-
DialogPrimitive__namespace.Overlay,
|
|
873
|
-
{
|
|
874
|
-
ref,
|
|
875
|
-
className: cn(
|
|
876
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-99999 bg-black/80",
|
|
877
|
-
className
|
|
878
|
-
),
|
|
879
|
-
...props
|
|
880
|
-
}
|
|
881
|
-
));
|
|
882
|
-
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
883
|
-
var DialogContent = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dark", children: [
|
|
884
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
885
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
886
|
-
DialogPrimitive__namespace.Content,
|
|
887
|
-
{
|
|
888
|
-
ref,
|
|
889
|
-
className: cn(
|
|
890
|
-
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-99999 w-full translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl border border-white p-6 shadow-lg duration-200",
|
|
891
|
-
className
|
|
892
|
-
),
|
|
893
|
-
...props,
|
|
894
|
-
children: [
|
|
895
|
-
children,
|
|
896
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "text-foreground ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none", children: [
|
|
897
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" }),
|
|
898
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
|
|
899
|
-
] })
|
|
900
|
-
]
|
|
901
|
-
}
|
|
902
|
-
)
|
|
903
|
-
] }) }));
|
|
904
|
-
DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
|
|
905
|
-
var DialogHeader = ({
|
|
906
|
-
className,
|
|
907
|
-
...props
|
|
908
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
909
|
-
"div",
|
|
910
|
-
{
|
|
911
|
-
className: cn(
|
|
912
|
-
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
913
|
-
className
|
|
914
|
-
),
|
|
915
|
-
...props
|
|
916
|
-
}
|
|
917
|
-
);
|
|
918
|
-
DialogHeader.displayName = "DialogHeader";
|
|
919
|
-
var DialogTitle = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
920
|
-
DialogPrimitive__namespace.Title,
|
|
921
|
-
{
|
|
922
|
-
ref,
|
|
923
|
-
className: cn(
|
|
924
|
-
"text-lg leading-none font-semibold tracking-tight",
|
|
925
|
-
className
|
|
926
|
-
),
|
|
927
|
-
...props
|
|
928
|
-
}
|
|
929
|
-
));
|
|
930
|
-
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
931
|
-
var DialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
932
|
-
DialogPrimitive__namespace.Description,
|
|
933
|
-
{
|
|
934
|
-
ref,
|
|
935
|
-
className: cn("text-muted-foreground text-sm", className),
|
|
936
|
-
...props
|
|
937
|
-
}
|
|
938
|
-
));
|
|
939
|
-
DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
|
|
940
|
-
var DebugStateDialog = ({
|
|
941
|
-
isOpen,
|
|
942
|
-
onClose,
|
|
943
|
-
getState,
|
|
944
|
-
title = "Debug State",
|
|
945
|
-
updateInterval = 100
|
|
946
|
-
}) => {
|
|
947
|
-
const [state, setState] = React.useState(() => getState());
|
|
948
|
-
const [copied, setCopied] = React.useState(false);
|
|
832
|
+
var useFullscreen = () => {
|
|
833
|
+
const [isFullscreen, setIsFullscreen] = React.useState(false);
|
|
949
834
|
React.useEffect(() => {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
835
|
+
const handleFullscreenChange = () => {
|
|
836
|
+
const doc = document;
|
|
837
|
+
setIsFullscreen(
|
|
838
|
+
!!(document.fullscreenElement || doc.webkitFullscreenElement || doc.mozFullScreenElement || doc.msFullscreenElement)
|
|
839
|
+
);
|
|
840
|
+
};
|
|
841
|
+
document.addEventListener("fullscreenchange", handleFullscreenChange);
|
|
842
|
+
document.addEventListener("webkitfullscreenchange", handleFullscreenChange);
|
|
843
|
+
document.addEventListener("mozfullscreenchange", handleFullscreenChange);
|
|
844
|
+
document.addEventListener("msfullscreenchange", handleFullscreenChange);
|
|
957
845
|
return () => {
|
|
958
|
-
|
|
959
|
-
|
|
846
|
+
document.removeEventListener("fullscreenchange", handleFullscreenChange);
|
|
847
|
+
document.removeEventListener(
|
|
848
|
+
"webkitfullscreenchange",
|
|
849
|
+
handleFullscreenChange
|
|
850
|
+
);
|
|
851
|
+
document.removeEventListener(
|
|
852
|
+
"mozfullscreenchange",
|
|
853
|
+
handleFullscreenChange
|
|
854
|
+
);
|
|
855
|
+
document.removeEventListener(
|
|
856
|
+
"msfullscreenchange",
|
|
857
|
+
handleFullscreenChange
|
|
858
|
+
);
|
|
960
859
|
};
|
|
961
|
-
}, [
|
|
962
|
-
const
|
|
963
|
-
const handleCopy = async () => {
|
|
860
|
+
}, []);
|
|
861
|
+
const exitFullscreen = React.useCallback(async () => {
|
|
964
862
|
try {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
863
|
+
const doc = document;
|
|
864
|
+
if (document.fullscreenElement || doc.webkitFullscreenElement || doc.mozFullScreenElement || doc.msFullscreenElement) {
|
|
865
|
+
if (document.exitFullscreen) {
|
|
866
|
+
await document.exitFullscreen();
|
|
867
|
+
} else if (doc.webkitExitFullscreen) {
|
|
868
|
+
await doc.webkitExitFullscreen();
|
|
869
|
+
} else if (doc.mozCancelFullScreen) {
|
|
870
|
+
await doc.mozCancelFullScreen();
|
|
871
|
+
} else if (doc.msExitFullscreen) {
|
|
872
|
+
await doc.msExitFullscreen();
|
|
873
|
+
}
|
|
874
|
+
}
|
|
968
875
|
} catch (error) {
|
|
969
|
-
console.error("
|
|
876
|
+
console.error("Error exiting fullscreen:", error);
|
|
970
877
|
}
|
|
971
|
-
};
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-4 w-4" })
|
|
984
|
-
}
|
|
985
|
-
),
|
|
986
|
-
/* @__PURE__ */ jsxRuntime.jsx("pre", { className: "bg-muted text-muted-foreground overflow-auto rounded-lg border p-4 font-mono text-xs", children: jsonString })
|
|
987
|
-
] })
|
|
988
|
-
] }) });
|
|
989
|
-
};
|
|
990
|
-
var AirJamDebug = ({
|
|
991
|
-
state,
|
|
992
|
-
title = "Debug State",
|
|
993
|
-
updateInterval = 100,
|
|
994
|
-
className
|
|
995
|
-
}) => {
|
|
996
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
997
|
-
const [currentState, setCurrentState] = React.useState(state);
|
|
998
|
-
React.useEffect(() => {
|
|
999
|
-
if (!isOpen) return;
|
|
1000
|
-
const interval = setInterval(() => {
|
|
1001
|
-
setCurrentState(state);
|
|
1002
|
-
}, updateInterval);
|
|
1003
|
-
setCurrentState(state);
|
|
1004
|
-
return () => clearInterval(interval);
|
|
1005
|
-
}, [isOpen, state, updateInterval]);
|
|
1006
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1007
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1008
|
-
Button,
|
|
1009
|
-
{
|
|
1010
|
-
type: "button",
|
|
1011
|
-
variant: "ghost",
|
|
1012
|
-
size: "icon",
|
|
1013
|
-
onClick: () => setIsOpen(true),
|
|
1014
|
-
"aria-label": "Debug state",
|
|
1015
|
-
title,
|
|
1016
|
-
className: `text-white hover:bg-white/20 hover:text-white ${className || ""}`,
|
|
1017
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bug, { className: "h-4 w-4" })
|
|
1018
|
-
}
|
|
1019
|
-
),
|
|
1020
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1021
|
-
DebugStateDialog,
|
|
1022
|
-
{
|
|
1023
|
-
isOpen,
|
|
1024
|
-
onClose: () => setIsOpen(false),
|
|
1025
|
-
getState: () => currentState,
|
|
1026
|
-
title,
|
|
1027
|
-
updateInterval
|
|
878
|
+
}, []);
|
|
879
|
+
const enterFullscreen = React.useCallback(async (element) => {
|
|
880
|
+
try {
|
|
881
|
+
const elem = element || document.documentElement;
|
|
882
|
+
if (elem.requestFullscreen) {
|
|
883
|
+
await elem.requestFullscreen();
|
|
884
|
+
} else if (elem.webkitRequestFullscreen) {
|
|
885
|
+
await elem.webkitRequestFullscreen();
|
|
886
|
+
} else if (elem.mozRequestFullScreen) {
|
|
887
|
+
await elem.mozRequestFullScreen();
|
|
888
|
+
} else if (elem.msRequestFullscreen) {
|
|
889
|
+
await elem.msRequestFullscreen();
|
|
1028
890
|
}
|
|
1029
|
-
)
|
|
1030
|
-
|
|
891
|
+
} catch (error) {
|
|
892
|
+
console.error("Error entering fullscreen:", error);
|
|
893
|
+
}
|
|
894
|
+
}, []);
|
|
895
|
+
const toggleFullscreen = React.useCallback(
|
|
896
|
+
async (element) => {
|
|
897
|
+
if (isFullscreen) {
|
|
898
|
+
await exitFullscreen();
|
|
899
|
+
} else {
|
|
900
|
+
await enterFullscreen(element);
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
[isFullscreen, exitFullscreen, enterFullscreen]
|
|
904
|
+
);
|
|
905
|
+
return {
|
|
906
|
+
isFullscreen,
|
|
907
|
+
enterFullscreen,
|
|
908
|
+
exitFullscreen,
|
|
909
|
+
toggleFullscreen
|
|
910
|
+
};
|
|
1031
911
|
};
|
|
1032
912
|
var roomCodeSchema = zod.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, { message: "room code must contain only A-Z or 0-9" });
|
|
1033
913
|
var controllerInputSchema = zod.z.object({
|
|
@@ -1102,6 +982,7 @@ var hostReconnectSchema = zod.z.object({
|
|
|
1102
982
|
apiKey: zod.z.string().optional()
|
|
1103
983
|
});
|
|
1104
984
|
var AIRJAM_PROXY_PREFIX = "AIRJAM_";
|
|
985
|
+
var cn = (...inputs) => tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
1105
986
|
|
|
1106
987
|
// src/utils/mode.ts
|
|
1107
988
|
var detectRunMode = () => {
|
|
@@ -1114,6 +995,47 @@ var detectRunMode = () => {
|
|
|
1114
995
|
return "platform";
|
|
1115
996
|
}
|
|
1116
997
|
};
|
|
998
|
+
var getPlayerAvatarUrl = (playerId) => {
|
|
999
|
+
return `https://api.dicebear.com/9.x/adventurer-neutral/svg?seed=${encodeURIComponent(
|
|
1000
|
+
playerId
|
|
1001
|
+
)}`;
|
|
1002
|
+
};
|
|
1003
|
+
var hexToRgba = (hex, opacity) => {
|
|
1004
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
1005
|
+
if (!result) return `rgba(0, 0, 0, ${opacity})`;
|
|
1006
|
+
const r = parseInt(result[1], 16);
|
|
1007
|
+
const g = parseInt(result[2], 16);
|
|
1008
|
+
const b = parseInt(result[3], 16);
|
|
1009
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
1010
|
+
};
|
|
1011
|
+
var PlayerAvatar = ({
|
|
1012
|
+
player,
|
|
1013
|
+
size = "md",
|
|
1014
|
+
className = ""
|
|
1015
|
+
}) => {
|
|
1016
|
+
const sizeClasses = {
|
|
1017
|
+
sm: "h-8 w-8 border-2",
|
|
1018
|
+
md: "h-12 w-12 border-4",
|
|
1019
|
+
lg: "h-16 w-16 border-4"
|
|
1020
|
+
};
|
|
1021
|
+
const shadowStyles = {
|
|
1022
|
+
sm: player.color ? `inset 0 0 4px rgba(0, 0, 0, 0.2), 0 0 8px ${hexToRgba(player.color, 0.4)}` : "inset 0 0 4px rgba(0, 0, 0, 0.2)",
|
|
1023
|
+
md: player.color ? `inset 0 0 10px rgba(0, 0, 0, 0.4), 0 0 20px ${hexToRgba(player.color, 0.6)}, 0 0 10px ${hexToRgba(player.color, 0.8)}` : "inset 0 0 10px rgba(0, 0, 0, 0.4), 0 0 20px hsl(var(--border) / 0.5)",
|
|
1024
|
+
lg: player.color ? `inset 0 0 12px rgba(0, 0, 0, 0.4), 0 0 24px ${hexToRgba(player.color, 0.6)}, 0 0 12px ${hexToRgba(player.color, 0.8)}` : "inset 0 0 12px rgba(0, 0, 0, 0.4), 0 0 24px hsl(var(--border) / 0.5)"
|
|
1025
|
+
};
|
|
1026
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1027
|
+
"img",
|
|
1028
|
+
{
|
|
1029
|
+
src: getPlayerAvatarUrl(player.id),
|
|
1030
|
+
alt: player.label,
|
|
1031
|
+
className: `bg-secondary/30 shrink-0 rounded-full shadow-lg ${sizeClasses[size]} ${className}`,
|
|
1032
|
+
style: {
|
|
1033
|
+
borderColor: player.color || "hsl(var(--border))",
|
|
1034
|
+
boxShadow: shadowStyles[size]
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
);
|
|
1038
|
+
};
|
|
1117
1039
|
|
|
1118
1040
|
// src/utils/network-ip.ts
|
|
1119
1041
|
var isVirtualNetwork = (ip) => {
|
|
@@ -1329,1676 +1251,1617 @@ var UrlBuilder = class {
|
|
|
1329
1251
|
}
|
|
1330
1252
|
};
|
|
1331
1253
|
var urlBuilder = new UrlBuilder();
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1254
|
+
var buttonVariants = classVarianceAuthority.cva(
|
|
1255
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
1256
|
+
{
|
|
1257
|
+
variants: {
|
|
1258
|
+
variant: {
|
|
1259
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
1260
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
1261
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
1262
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
1263
|
+
ghost: "text-foreground hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
1264
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
1265
|
+
},
|
|
1266
|
+
size: {
|
|
1267
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
1268
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
1269
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
1270
|
+
icon: "size-9",
|
|
1271
|
+
"icon-sm": "size-8",
|
|
1272
|
+
"icon-lg": "size-10"
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1275
|
+
defaultVariants: {
|
|
1276
|
+
variant: "default",
|
|
1277
|
+
size: "default"
|
|
1343
1278
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1279
|
+
}
|
|
1280
|
+
);
|
|
1281
|
+
function Button({
|
|
1282
|
+
className,
|
|
1283
|
+
variant,
|
|
1284
|
+
size,
|
|
1285
|
+
asChild = false,
|
|
1286
|
+
...props
|
|
1287
|
+
}) {
|
|
1288
|
+
const Comp = asChild ? reactSlot.Slot : "button";
|
|
1289
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1290
|
+
Comp,
|
|
1291
|
+
{
|
|
1292
|
+
"data-slot": "button",
|
|
1293
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
1294
|
+
...props
|
|
1355
1295
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
var extractRoomCode = (text) => {
|
|
1299
|
+
try {
|
|
1300
|
+
const url = new URL(text);
|
|
1301
|
+
const roomParam = url.searchParams.get("room");
|
|
1302
|
+
if (roomParam) {
|
|
1303
|
+
const parsed2 = roomCodeSchema.safeParse(roomParam.toUpperCase());
|
|
1304
|
+
if (parsed2.success) {
|
|
1305
|
+
return parsed2.data;
|
|
1362
1306
|
}
|
|
1363
1307
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1308
|
+
} catch {
|
|
1309
|
+
}
|
|
1310
|
+
const parsed = roomCodeSchema.safeParse(text.trim().toUpperCase());
|
|
1311
|
+
if (parsed.success) {
|
|
1312
|
+
return parsed.data;
|
|
1313
|
+
}
|
|
1314
|
+
return null;
|
|
1315
|
+
};
|
|
1316
|
+
var QRScannerDialog = ({
|
|
1317
|
+
isOpen,
|
|
1318
|
+
onClose,
|
|
1319
|
+
onScan,
|
|
1320
|
+
currentRoomId
|
|
1321
|
+
}) => {
|
|
1322
|
+
const [code, setCode] = React.useState("");
|
|
1323
|
+
const [isCameraAvailable, setIsCameraAvailable] = React.useState(false);
|
|
1369
1324
|
const [joinUrl, setJoinUrl] = React.useState("");
|
|
1370
|
-
const
|
|
1371
|
-
const
|
|
1372
|
-
const
|
|
1325
|
+
const [copied, setCopied] = React.useState(false);
|
|
1326
|
+
const scannerRef = React.useRef(null);
|
|
1327
|
+
const inputRef = React.useRef(null);
|
|
1328
|
+
const prevIsOpenRef = React.useRef(false);
|
|
1373
1329
|
React.useEffect(() => {
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
lastError: state.lastError,
|
|
1383
|
-
players: state.players,
|
|
1384
|
-
gameState: state.gameState,
|
|
1385
|
-
mode: state.mode,
|
|
1386
|
-
roomId: state.roomId
|
|
1387
|
-
}))
|
|
1388
|
-
);
|
|
1389
|
-
const socket = React.useMemo(
|
|
1390
|
-
() => getSocket("host") ,
|
|
1391
|
-
[shouldConnect, getSocket]
|
|
1392
|
-
);
|
|
1393
|
-
const [lastToggle, setLastToggle] = React.useState(0);
|
|
1394
|
-
const toggleGameState = React.useCallback(() => {
|
|
1395
|
-
const now = Date.now();
|
|
1396
|
-
if (now - lastToggle < TOGGLE_DEBOUNCE_MS) {
|
|
1397
|
-
return;
|
|
1398
|
-
}
|
|
1399
|
-
setLastToggle(now);
|
|
1400
|
-
if (!socket || !socket.connected) {
|
|
1401
|
-
return;
|
|
1402
|
-
}
|
|
1403
|
-
if (!parsedRoomId) return;
|
|
1404
|
-
const payload = controllerSystemSchema.safeParse({
|
|
1405
|
-
roomId: parsedRoomId,
|
|
1406
|
-
command: "toggle_pause"
|
|
1407
|
-
});
|
|
1408
|
-
if (payload.success) {
|
|
1409
|
-
socket.emit("host:system", payload.data);
|
|
1330
|
+
if (isOpen && !prevIsOpenRef.current) {
|
|
1331
|
+
const initialCode = currentRoomId || "";
|
|
1332
|
+
setTimeout(() => {
|
|
1333
|
+
setIsCameraAvailable(false);
|
|
1334
|
+
setCode(initialCode);
|
|
1335
|
+
inputRef.current?.focus();
|
|
1336
|
+
inputRef.current?.select();
|
|
1337
|
+
}, 0);
|
|
1410
1338
|
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1339
|
+
prevIsOpenRef.current = isOpen;
|
|
1340
|
+
}, [isOpen, currentRoomId]);
|
|
1341
|
+
React.useEffect(() => {
|
|
1342
|
+
const buildUrl = async () => {
|
|
1343
|
+
const trimmed = code.trim().toUpperCase();
|
|
1344
|
+
const parsed = roomCodeSchema.safeParse(trimmed);
|
|
1345
|
+
if (parsed.success) {
|
|
1346
|
+
try {
|
|
1347
|
+
const url = await urlBuilder.buildControllerUrl(parsed.data);
|
|
1348
|
+
setJoinUrl(url);
|
|
1349
|
+
} catch {
|
|
1350
|
+
setJoinUrl("");
|
|
1351
|
+
}
|
|
1352
|
+
} else {
|
|
1353
|
+
setJoinUrl("");
|
|
1423
1354
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1355
|
+
};
|
|
1356
|
+
buildUrl();
|
|
1357
|
+
}, [code]);
|
|
1358
|
+
React.useEffect(() => {
|
|
1359
|
+
if (!isOpen) {
|
|
1360
|
+
setTimeout(() => {
|
|
1361
|
+
setIsCameraAvailable(false);
|
|
1362
|
+
}, 0);
|
|
1363
|
+
if (scannerRef.current) {
|
|
1364
|
+
const scanner = scannerRef.current;
|
|
1365
|
+
scanner.stop().catch(() => {
|
|
1366
|
+
}).finally(() => {
|
|
1367
|
+
try {
|
|
1368
|
+
scanner.clear();
|
|
1369
|
+
} catch {
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
scannerRef.current = null;
|
|
1433
1373
|
}
|
|
1434
|
-
const signal = {
|
|
1435
|
-
targetId,
|
|
1436
|
-
type,
|
|
1437
|
-
payload
|
|
1438
|
-
};
|
|
1439
|
-
socket.emit("host:signal", signal);
|
|
1440
|
-
},
|
|
1441
|
-
[socket]
|
|
1442
|
-
);
|
|
1443
|
-
const reconnect = React.useCallback(() => {
|
|
1444
|
-
disconnectSocket("host");
|
|
1445
|
-
if (socket) {
|
|
1446
|
-
socket.connect();
|
|
1447
1374
|
}
|
|
1448
|
-
}, [
|
|
1449
|
-
React.useEffect(() => {
|
|
1450
|
-
if (!parsedRoomId) return;
|
|
1451
|
-
(async () => {
|
|
1452
|
-
const url = await urlBuilder.buildControllerUrl(parsedRoomId, {
|
|
1453
|
-
host: config.publicHost
|
|
1454
|
-
});
|
|
1455
|
-
setJoinUrl(url);
|
|
1456
|
-
})();
|
|
1457
|
-
}, [parsedRoomId, config.publicHost, options.roomId]);
|
|
1458
|
-
const setRegisteredRoomId = zustand.useStore(store, (s) => s.setRegisteredRoomId);
|
|
1375
|
+
}, [isOpen]);
|
|
1459
1376
|
React.useEffect(() => {
|
|
1460
|
-
|
|
1461
|
-
storeState.setMode(detectRunMode());
|
|
1462
|
-
storeState.setRole("host");
|
|
1463
|
-
if (parsedRoomId) {
|
|
1464
|
-
storeState.setRoomId(parsedRoomId);
|
|
1465
|
-
}
|
|
1466
|
-
storeState.setStatus("connecting");
|
|
1467
|
-
storeState.setError(void 0);
|
|
1468
|
-
if (!socket) {
|
|
1469
|
-
storeState.setStatus("idle");
|
|
1377
|
+
if (!isOpen) {
|
|
1470
1378
|
return;
|
|
1471
1379
|
}
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1380
|
+
const containerId = "qr-reader";
|
|
1381
|
+
let scanner = null;
|
|
1382
|
+
let scannerRunning = false;
|
|
1383
|
+
let mounted = true;
|
|
1384
|
+
const startScanning = async () => {
|
|
1385
|
+
try {
|
|
1386
|
+
const container = document.getElementById(containerId);
|
|
1387
|
+
if (!container) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
const rect = container.getBoundingClientRect();
|
|
1391
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
scanner = new html5Qrcode.Html5Qrcode(containerId);
|
|
1395
|
+
scannerRef.current = scanner;
|
|
1396
|
+
let cameraId = null;
|
|
1397
|
+
try {
|
|
1398
|
+
const devices = await html5Qrcode.Html5Qrcode.getCameras();
|
|
1399
|
+
if (devices && devices.length > 0) {
|
|
1400
|
+
const backCamera = devices.find(
|
|
1401
|
+
(d) => d.label.toLowerCase().includes("back") || d.label.toLowerCase().includes("rear")
|
|
1402
|
+
);
|
|
1403
|
+
const envCamera = devices.find((d) => {
|
|
1404
|
+
const label = d.label.toLowerCase();
|
|
1405
|
+
return label.includes("environment") || label.includes("facing back");
|
|
1406
|
+
});
|
|
1407
|
+
cameraId = (envCamera || backCamera || devices[0])?.id || null;
|
|
1492
1408
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1521
|
-
});
|
|
1522
|
-
};
|
|
1523
|
-
if (typeof window !== "undefined") {
|
|
1524
|
-
const savedRoomId = sessionStorage.getItem("airjam_room_id");
|
|
1525
|
-
if (savedRoomId) {
|
|
1526
|
-
const reconnectPayload = hostReconnectSchema.parse({
|
|
1527
|
-
roomId: savedRoomId,
|
|
1528
|
-
apiKey: options.apiKey ?? config.apiKey
|
|
1529
|
-
});
|
|
1530
|
-
socket.emit("host:reconnect", reconnectPayload, (ack) => {
|
|
1531
|
-
if (ack.ok && ack.roomId) {
|
|
1532
|
-
storeState2.setStatus("connected");
|
|
1533
|
-
storeState2.setRoomId(ack.roomId);
|
|
1534
|
-
setRegisteredRoomId(ack.roomId);
|
|
1535
|
-
} else {
|
|
1536
|
-
if (typeof window !== "undefined") {
|
|
1537
|
-
sessionStorage.removeItem("airjam_room_id");
|
|
1409
|
+
} catch {
|
|
1410
|
+
}
|
|
1411
|
+
const config = cameraId ? { deviceId: { exact: cameraId } } : { facingMode: "environment" };
|
|
1412
|
+
await scanner.start(
|
|
1413
|
+
config,
|
|
1414
|
+
{
|
|
1415
|
+
fps: 10,
|
|
1416
|
+
qrbox: (viewfinderWidth, viewfinderHeight) => {
|
|
1417
|
+
const minEdge = Math.min(viewfinderWidth, viewfinderHeight);
|
|
1418
|
+
const qrboxSize = Math.min(250, minEdge * 0.8);
|
|
1419
|
+
return {
|
|
1420
|
+
width: qrboxSize,
|
|
1421
|
+
height: qrboxSize
|
|
1422
|
+
};
|
|
1423
|
+
},
|
|
1424
|
+
aspectRatio: 1
|
|
1425
|
+
},
|
|
1426
|
+
(decodedText) => {
|
|
1427
|
+
if (!mounted) return;
|
|
1428
|
+
const roomCode = extractRoomCode(decodedText);
|
|
1429
|
+
if (roomCode) {
|
|
1430
|
+
setCode(roomCode);
|
|
1431
|
+
scannerRunning = false;
|
|
1432
|
+
scanner?.stop().catch(() => {
|
|
1433
|
+
}).finally(() => {
|
|
1434
|
+
if (mounted) {
|
|
1435
|
+
setIsCameraAvailable(false);
|
|
1538
1436
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
createNewRoom();
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
() => {
|
|
1544
1441
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1442
|
+
);
|
|
1443
|
+
scannerRunning = true;
|
|
1444
|
+
if (mounted) {
|
|
1445
|
+
setIsCameraAvailable(true);
|
|
1547
1446
|
}
|
|
1447
|
+
} catch {
|
|
1448
|
+
if (mounted) {
|
|
1449
|
+
setIsCameraAvailable(false);
|
|
1450
|
+
}
|
|
1451
|
+
if (scanner) {
|
|
1452
|
+
try {
|
|
1453
|
+
scanner.clear();
|
|
1454
|
+
} catch {
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
scannerRef.current = null;
|
|
1548
1458
|
}
|
|
1549
1459
|
};
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
const handleInput = (payload) => {
|
|
1570
|
-
if (inputManager) {
|
|
1571
|
-
inputManager.handleInput(payload);
|
|
1572
|
-
}
|
|
1573
|
-
};
|
|
1574
|
-
const handleChildClose = () => {
|
|
1575
|
-
onChildCloseRef.current?.();
|
|
1576
|
-
};
|
|
1577
|
-
const handleState = (payload) => {
|
|
1578
|
-
if (!parsedRoomId || payload.roomId !== parsedRoomId) return;
|
|
1579
|
-
const storeState2 = store.getState();
|
|
1580
|
-
if (payload.state.gameState) {
|
|
1581
|
-
storeState2.setGameState(payload.state.gameState);
|
|
1582
|
-
}
|
|
1583
|
-
if (payload.state.message !== void 0) {
|
|
1584
|
-
storeState2.setStateMessage(payload.state.message);
|
|
1460
|
+
const timeoutId = setTimeout(() => {
|
|
1461
|
+
startScanning();
|
|
1462
|
+
}, 200);
|
|
1463
|
+
return () => {
|
|
1464
|
+
mounted = false;
|
|
1465
|
+
clearTimeout(timeoutId);
|
|
1466
|
+
if (scanner && scannerRunning) {
|
|
1467
|
+
scanner.stop().catch(() => {
|
|
1468
|
+
}).finally(() => {
|
|
1469
|
+
try {
|
|
1470
|
+
scanner?.clear();
|
|
1471
|
+
} catch {
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
} else if (scanner) {
|
|
1475
|
+
try {
|
|
1476
|
+
scanner.clear();
|
|
1477
|
+
} catch {
|
|
1478
|
+
}
|
|
1585
1479
|
}
|
|
1480
|
+
scannerRef.current = null;
|
|
1586
1481
|
};
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
socket.on("server:input", handleInput);
|
|
1595
|
-
socket.on("server:error", handleError);
|
|
1596
|
-
socket.on("server:closeChild", handleChildClose);
|
|
1597
|
-
socket.on("server:state", handleState);
|
|
1598
|
-
socket.connect();
|
|
1599
|
-
const currentRegisteredRoomId = store.getState().registeredRoomId;
|
|
1600
|
-
if (socket.connected && !currentRegisteredRoomId) {
|
|
1601
|
-
registerHost();
|
|
1482
|
+
}, [isOpen]);
|
|
1483
|
+
const handleSubmit = () => {
|
|
1484
|
+
const trimmed = code.trim().toUpperCase();
|
|
1485
|
+
const parsed = roomCodeSchema.safeParse(trimmed);
|
|
1486
|
+
if (parsed.success) {
|
|
1487
|
+
onScan(parsed.data);
|
|
1488
|
+
onClose();
|
|
1602
1489
|
}
|
|
1603
|
-
return () => {
|
|
1604
|
-
socket.off("connect", handleConnect);
|
|
1605
|
-
socket.off("disconnect", handleDisconnect);
|
|
1606
|
-
socket.off("server:controllerJoined", handleJoin);
|
|
1607
|
-
socket.off("server:controllerLeft", handleLeave);
|
|
1608
|
-
socket.off("server:input", handleInput);
|
|
1609
|
-
socket.off("server:error", handleError);
|
|
1610
|
-
socket.off("server:closeChild", handleChildClose);
|
|
1611
|
-
socket.off("server:state", handleState);
|
|
1612
|
-
};
|
|
1613
|
-
}, [
|
|
1614
|
-
config.maxPlayers,
|
|
1615
|
-
config.apiKey,
|
|
1616
|
-
options.maxPlayers,
|
|
1617
|
-
options.apiKey,
|
|
1618
|
-
arcadeParams,
|
|
1619
|
-
parsedRoomId,
|
|
1620
|
-
// Include parsedRoomId since it's used in handleState callback
|
|
1621
|
-
shouldConnect,
|
|
1622
|
-
socket,
|
|
1623
|
-
store,
|
|
1624
|
-
inputManager,
|
|
1625
|
-
setRegisteredRoomId
|
|
1626
|
-
]);
|
|
1627
|
-
const returnSocket = socket ?? getSocket("host");
|
|
1628
|
-
const getInput = React.useCallback(
|
|
1629
|
-
(controllerId) => {
|
|
1630
|
-
if (!inputManager) {
|
|
1631
|
-
return void 0;
|
|
1632
|
-
}
|
|
1633
|
-
return inputManager.getInput(controllerId);
|
|
1634
|
-
},
|
|
1635
|
-
[inputManager]
|
|
1636
|
-
);
|
|
1637
|
-
return {
|
|
1638
|
-
roomId: parsedRoomId ?? "",
|
|
1639
|
-
// Return empty string as fallback if not yet available
|
|
1640
|
-
joinUrl,
|
|
1641
|
-
connectionStatus: connectionState.connectionStatus,
|
|
1642
|
-
players: connectionState.players,
|
|
1643
|
-
lastError: connectionState.lastError,
|
|
1644
|
-
mode: connectionState.mode,
|
|
1645
|
-
gameState: connectionState.gameState,
|
|
1646
|
-
toggleGameState,
|
|
1647
|
-
sendState,
|
|
1648
|
-
sendSignal,
|
|
1649
|
-
reconnect,
|
|
1650
|
-
socket: returnSocket,
|
|
1651
|
-
isChildMode,
|
|
1652
|
-
getInput
|
|
1653
1490
|
};
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
return `https://api.dicebear.com/9.x/adventurer-neutral/svg?seed=${encodeURIComponent(
|
|
1657
|
-
playerId
|
|
1658
|
-
)}`;
|
|
1659
|
-
};
|
|
1660
|
-
var hexToRgba = (hex, opacity) => {
|
|
1661
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
1662
|
-
if (!result) return `rgba(0, 0, 0, ${opacity})`;
|
|
1663
|
-
const r = parseInt(result[1], 16);
|
|
1664
|
-
const g = parseInt(result[2], 16);
|
|
1665
|
-
const b = parseInt(result[3], 16);
|
|
1666
|
-
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
1667
|
-
};
|
|
1668
|
-
var PlayerAvatar = ({
|
|
1669
|
-
player,
|
|
1670
|
-
size = "md",
|
|
1671
|
-
className = ""
|
|
1672
|
-
}) => {
|
|
1673
|
-
const sizeClasses = {
|
|
1674
|
-
sm: "h-8 w-8 border-2",
|
|
1675
|
-
md: "h-12 w-12 border-4",
|
|
1676
|
-
lg: "h-16 w-16 border-4"
|
|
1491
|
+
const handleInputFocus = (e) => {
|
|
1492
|
+
e.target.select();
|
|
1677
1493
|
};
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
lg: player.color ? `inset 0 0 12px rgba(0, 0, 0, 0.4), 0 0 24px ${hexToRgba(player.color, 0.6)}, 0 0 12px ${hexToRgba(player.color, 0.8)}` : "inset 0 0 12px rgba(0, 0, 0, 0.4), 0 0 24px hsl(var(--border) / 0.5)"
|
|
1494
|
+
const handleInputChange = (e) => {
|
|
1495
|
+
setCode(e.target.value.toUpperCase());
|
|
1496
|
+
setCopied(false);
|
|
1682
1497
|
};
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
{
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1498
|
+
const handleCopyUrl = async () => {
|
|
1499
|
+
if (!joinUrl) return;
|
|
1500
|
+
try {
|
|
1501
|
+
await navigator.clipboard.writeText(joinUrl);
|
|
1502
|
+
setCopied(true);
|
|
1503
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
1504
|
+
} catch {
|
|
1505
|
+
const textArea = document.createElement("textarea");
|
|
1506
|
+
textArea.value = joinUrl;
|
|
1507
|
+
textArea.style.position = "fixed";
|
|
1508
|
+
textArea.style.opacity = "0";
|
|
1509
|
+
document.body.appendChild(textArea);
|
|
1510
|
+
textArea.select();
|
|
1511
|
+
try {
|
|
1512
|
+
document.execCommand("copy");
|
|
1513
|
+
setCopied(true);
|
|
1514
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
1515
|
+
} catch {
|
|
1692
1516
|
}
|
|
1517
|
+
document.body.removeChild(textArea);
|
|
1693
1518
|
}
|
|
1694
|
-
|
|
1519
|
+
};
|
|
1520
|
+
if (!isOpen) {
|
|
1521
|
+
return null;
|
|
1522
|
+
}
|
|
1523
|
+
const isValid = code.trim().length > 0;
|
|
1524
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-background fixed inset-0 z-50 flex flex-col items-center justify-center", children: [
|
|
1525
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col items-center justify-center", children: [
|
|
1526
|
+
isCameraAvailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex aspect-square w-full items-center justify-center overflow-hidden p-6", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1527
|
+
"div",
|
|
1528
|
+
{
|
|
1529
|
+
id: "qr-reader",
|
|
1530
|
+
className: "h-full w-full overflow-hidden rounded-lg bg-black"
|
|
1531
|
+
}
|
|
1532
|
+
) }),
|
|
1533
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full max-w-md px-6", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1534
|
+
"input",
|
|
1535
|
+
{
|
|
1536
|
+
ref: inputRef,
|
|
1537
|
+
type: "text",
|
|
1538
|
+
value: code,
|
|
1539
|
+
onChange: handleInputChange,
|
|
1540
|
+
onFocus: handleInputFocus,
|
|
1541
|
+
onKeyDown: (e) => {
|
|
1542
|
+
if (e.key === "Enter" && isValid) {
|
|
1543
|
+
handleSubmit();
|
|
1544
|
+
}
|
|
1545
|
+
},
|
|
1546
|
+
placeholder: "Enter room code",
|
|
1547
|
+
className: "border-border bg-background focus:ring-primary focus:border-primary w-full rounded-lg border-2 px-6 py-4 text-center font-mono text-2xl focus:ring-2 focus:outline-none",
|
|
1548
|
+
autoComplete: "off",
|
|
1549
|
+
autoCapitalize: "characters"
|
|
1550
|
+
}
|
|
1551
|
+
) }),
|
|
1552
|
+
joinUrl && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 w-full max-w-md px-6 pb-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1553
|
+
"button",
|
|
1554
|
+
{
|
|
1555
|
+
type: "button",
|
|
1556
|
+
onClick: handleCopyUrl,
|
|
1557
|
+
className: "text-muted-foreground hover:text-foreground bg-muted/50 hover:bg-muted w-full rounded-lg px-4 py-3 text-center font-mono text-xs break-all transition-colors",
|
|
1558
|
+
children: copied ? "\u2713 Copied!" : joinUrl
|
|
1559
|
+
}
|
|
1560
|
+
) })
|
|
1561
|
+
] }),
|
|
1562
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-md gap-4 px-6 pb-6", children: [
|
|
1563
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1564
|
+
Button,
|
|
1565
|
+
{
|
|
1566
|
+
type: "button",
|
|
1567
|
+
variant: "outline",
|
|
1568
|
+
onClick: onClose,
|
|
1569
|
+
className: "flex-1 py-6",
|
|
1570
|
+
children: "Cancel"
|
|
1571
|
+
}
|
|
1572
|
+
),
|
|
1573
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1574
|
+
Button,
|
|
1575
|
+
{
|
|
1576
|
+
type: "button",
|
|
1577
|
+
onClick: handleSubmit,
|
|
1578
|
+
disabled: !isValid,
|
|
1579
|
+
className: "flex-1 py-6",
|
|
1580
|
+
children: "Connect"
|
|
1581
|
+
}
|
|
1582
|
+
)
|
|
1583
|
+
] })
|
|
1584
|
+
] });
|
|
1695
1585
|
};
|
|
1696
|
-
var
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1586
|
+
var describeStatus = (status) => {
|
|
1587
|
+
switch (status) {
|
|
1588
|
+
case "connected":
|
|
1589
|
+
return "Connected to host";
|
|
1590
|
+
case "connecting":
|
|
1591
|
+
return "Connecting\u2026";
|
|
1592
|
+
case "reconnecting":
|
|
1593
|
+
return "Trying to reconnect\u2026";
|
|
1594
|
+
case "disconnected":
|
|
1595
|
+
return "Disconnected";
|
|
1596
|
+
case "idle":
|
|
1597
|
+
default:
|
|
1598
|
+
return "Idle";
|
|
1708
1599
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1600
|
+
};
|
|
1601
|
+
var orientationMatches = (required) => {
|
|
1602
|
+
if (!required) return true;
|
|
1603
|
+
if (typeof window === "undefined" || !window.matchMedia) return true;
|
|
1604
|
+
const matcher = window.matchMedia(`(orientation: ${required})`);
|
|
1605
|
+
return matcher.matches;
|
|
1606
|
+
};
|
|
1607
|
+
var ControllerShell = ({
|
|
1608
|
+
forceOrientation,
|
|
1609
|
+
children,
|
|
1610
|
+
customActions
|
|
1611
|
+
}) => {
|
|
1612
|
+
const { store, getSocket, disconnectSocket } = useAirJamContext();
|
|
1613
|
+
const isChildMode = React.useMemo(() => detectRunMode() === "platform", []);
|
|
1614
|
+
const [isOrientationOk, setOrientationOk] = React.useState(
|
|
1615
|
+
() => orientationMatches(forceOrientation)
|
|
1723
1616
|
);
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
className
|
|
1736
|
-
),
|
|
1737
|
-
...props
|
|
1738
|
-
}
|
|
1617
|
+
const [isScannerOpen, setIsScannerOpen] = React.useState(false);
|
|
1618
|
+
const { isFullscreen, toggleFullscreen } = useFullscreen();
|
|
1619
|
+
const { roomId, connectionStatus, gameState, controllerId, players } = zustand.useStore(
|
|
1620
|
+
store,
|
|
1621
|
+
shallow.useShallow((state) => ({
|
|
1622
|
+
roomId: state.roomId,
|
|
1623
|
+
connectionStatus: state.connectionStatus,
|
|
1624
|
+
gameState: state.gameState,
|
|
1625
|
+
controllerId: state.controllerId,
|
|
1626
|
+
players: state.players
|
|
1627
|
+
}))
|
|
1739
1628
|
);
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1629
|
+
const socket = React.useMemo(() => getSocket("controller"), [getSocket]);
|
|
1630
|
+
const currentPlayer = React.useMemo(() => {
|
|
1631
|
+
if (!controllerId) return null;
|
|
1632
|
+
const found = players.find((p) => p.id === controllerId);
|
|
1633
|
+
if (!found && connectionStatus === "connected" && players.length > 0) ;
|
|
1634
|
+
return found || null;
|
|
1635
|
+
}, [controllerId, players, connectionStatus]);
|
|
1636
|
+
const sendSystemCommand = React.useCallback(
|
|
1637
|
+
(command) => {
|
|
1638
|
+
const storeState = store.getState();
|
|
1639
|
+
if (!roomId || !storeState.controllerId || !socket) return;
|
|
1640
|
+
if (!socket.connected) return;
|
|
1641
|
+
const payload = controllerSystemSchema.safeParse({
|
|
1642
|
+
roomId,
|
|
1643
|
+
command
|
|
1644
|
+
});
|
|
1645
|
+
if (payload.success) {
|
|
1646
|
+
socket.emit("controller:system", payload.data);
|
|
1750
1647
|
}
|
|
1751
1648
|
},
|
|
1752
|
-
|
|
1753
|
-
variant: "default"
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
);
|
|
1757
|
-
function Badge({
|
|
1758
|
-
className,
|
|
1759
|
-
variant,
|
|
1760
|
-
asChild = false,
|
|
1761
|
-
...props
|
|
1762
|
-
}) {
|
|
1763
|
-
const Comp = asChild ? reactSlot.Slot : "span";
|
|
1764
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1765
|
-
Comp,
|
|
1766
|
-
{
|
|
1767
|
-
"data-slot": "badge",
|
|
1768
|
-
className: cn(badgeVariants({ variant }), className),
|
|
1769
|
-
...props
|
|
1770
|
-
}
|
|
1649
|
+
[roomId, socket, store]
|
|
1771
1650
|
);
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
),
|
|
1782
|
-
...props
|
|
1651
|
+
const reconnect = React.useCallback(() => {
|
|
1652
|
+
if (!roomId) return;
|
|
1653
|
+
disconnectSocket("controller");
|
|
1654
|
+
store.getState().setRoomId(roomId);
|
|
1655
|
+
}, [roomId, disconnectSocket, store]);
|
|
1656
|
+
React.useEffect(() => {
|
|
1657
|
+
if (!forceOrientation) {
|
|
1658
|
+
setOrientationOk(true);
|
|
1659
|
+
return;
|
|
1783
1660
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
"
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1661
|
+
const media = window.matchMedia(`(orientation: ${forceOrientation})`);
|
|
1662
|
+
const handleChange = () => setOrientationOk(media.matches);
|
|
1663
|
+
handleChange();
|
|
1664
|
+
media.addEventListener("change", handleChange);
|
|
1665
|
+
return () => media.removeEventListener("change", handleChange);
|
|
1666
|
+
}, [forceOrientation]);
|
|
1667
|
+
const orientationOk = !forceOrientation ? true : isOrientationOk;
|
|
1668
|
+
const statusDotColor = React.useMemo(() => {
|
|
1669
|
+
switch (connectionStatus) {
|
|
1670
|
+
case "connected":
|
|
1671
|
+
return "bg-green-500";
|
|
1672
|
+
case "connecting":
|
|
1673
|
+
case "reconnecting":
|
|
1674
|
+
return "bg-yellow-500";
|
|
1675
|
+
case "disconnected":
|
|
1676
|
+
default:
|
|
1677
|
+
return "bg-red-500";
|
|
1793
1678
|
}
|
|
1794
|
-
);
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
"data-slot": "tabs",
|
|
1824
|
-
className: cn("flex flex-col gap-2", className),
|
|
1825
|
-
...props
|
|
1826
|
-
}
|
|
1827
|
-
);
|
|
1828
|
-
}
|
|
1829
|
-
function TabsList({
|
|
1830
|
-
className,
|
|
1831
|
-
...props
|
|
1832
|
-
}) {
|
|
1833
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1834
|
-
TabsPrimitive__namespace.List,
|
|
1835
|
-
{
|
|
1836
|
-
"data-slot": "tabs-list",
|
|
1837
|
-
className: cn(
|
|
1838
|
-
"bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
|
|
1839
|
-
className
|
|
1840
|
-
),
|
|
1841
|
-
...props
|
|
1842
|
-
}
|
|
1843
|
-
);
|
|
1844
|
-
}
|
|
1845
|
-
function TabsTrigger({
|
|
1846
|
-
className,
|
|
1847
|
-
...props
|
|
1848
|
-
}) {
|
|
1849
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1850
|
-
TabsPrimitive__namespace.Trigger,
|
|
1851
|
-
{
|
|
1852
|
-
"data-slot": "tabs-trigger",
|
|
1853
|
-
className: cn(
|
|
1854
|
-
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1855
|
-
className
|
|
1856
|
-
),
|
|
1857
|
-
...props
|
|
1858
|
-
}
|
|
1859
|
-
);
|
|
1860
|
-
}
|
|
1861
|
-
function TabsContent({
|
|
1862
|
-
className,
|
|
1863
|
-
...props
|
|
1864
|
-
}) {
|
|
1865
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1866
|
-
TabsPrimitive__namespace.Content,
|
|
1867
|
-
{
|
|
1868
|
-
"data-slot": "tabs-content",
|
|
1869
|
-
className: cn("flex-1 outline-none", className),
|
|
1870
|
-
...props
|
|
1871
|
-
}
|
|
1872
|
-
);
|
|
1873
|
-
}
|
|
1874
|
-
function Slider({
|
|
1875
|
-
className,
|
|
1876
|
-
defaultValue,
|
|
1877
|
-
value,
|
|
1878
|
-
min = 0,
|
|
1879
|
-
max = 100,
|
|
1880
|
-
...props
|
|
1881
|
-
}) {
|
|
1882
|
-
const _values = React__namespace.useMemo(
|
|
1883
|
-
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1884
|
-
[value, defaultValue, min, max]
|
|
1885
|
-
);
|
|
1886
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1887
|
-
SliderPrimitive__namespace.Root,
|
|
1888
|
-
{
|
|
1889
|
-
"data-slot": "slider",
|
|
1890
|
-
defaultValue,
|
|
1891
|
-
value,
|
|
1892
|
-
min,
|
|
1893
|
-
max,
|
|
1894
|
-
className: cn(
|
|
1895
|
-
"relative flex w-full cursor-pointer touch-none items-center select-none data-disabled:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
1896
|
-
className
|
|
1897
|
-
),
|
|
1898
|
-
...props,
|
|
1899
|
-
children: [
|
|
1900
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1901
|
-
SliderPrimitive__namespace.Track,
|
|
1679
|
+
}, [connectionStatus]);
|
|
1680
|
+
if (isChildMode) {
|
|
1681
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dark", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground relative flex h-dvh w-dvw touch-none flex-col overflow-hidden bg-black select-none", children: /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "relative flex min-h-0 flex-1 items-center justify-center overflow-hidden p-2 select-none sm:p-4", children: [
|
|
1682
|
+
!orientationOk && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-background/95 absolute inset-0 z-50 flex flex-col items-center justify-center p-6 text-center shadow-lg backdrop-blur-sm", children: [
|
|
1683
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-card-foreground text-xl font-semibold", children: "Rotate your device" }),
|
|
1684
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground mt-2 text-sm", children: [
|
|
1685
|
+
"This game is best experienced in ",
|
|
1686
|
+
forceOrientation,
|
|
1687
|
+
" ",
|
|
1688
|
+
"orientation."
|
|
1689
|
+
] })
|
|
1690
|
+
] }),
|
|
1691
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1692
|
+
"div",
|
|
1693
|
+
{
|
|
1694
|
+
className: cn(
|
|
1695
|
+
"h-full w-full select-none",
|
|
1696
|
+
!orientationOk && "pointer-events-none opacity-30"
|
|
1697
|
+
),
|
|
1698
|
+
children
|
|
1699
|
+
}
|
|
1700
|
+
)
|
|
1701
|
+
] }) }) });
|
|
1702
|
+
}
|
|
1703
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dark", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-foreground relative flex h-dvh w-dvw touch-none flex-col overflow-hidden bg-black select-none", children: [
|
|
1704
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "pointer-events-none sticky top-0 z-50 flex items-center justify-between border-b px-6 py-2", children: [
|
|
1705
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pointer-events-auto flex items-center gap-3", children: [
|
|
1706
|
+
typeof window !== "undefined" && (currentPlayer || controllerId) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1707
|
+
"div",
|
|
1902
1708
|
{
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1709
|
+
className: "relative",
|
|
1710
|
+
title: describeStatus(connectionStatus),
|
|
1711
|
+
children: [
|
|
1712
|
+
currentPlayer ? /* @__PURE__ */ jsxRuntime.jsx(PlayerAvatar, { player: currentPlayer, size: "sm" }) : controllerId ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1713
|
+
PlayerAvatar,
|
|
1714
|
+
{
|
|
1715
|
+
player: {
|
|
1716
|
+
id: controllerId,
|
|
1717
|
+
label: "Player"
|
|
1718
|
+
},
|
|
1719
|
+
size: "sm"
|
|
1720
|
+
}
|
|
1721
|
+
) : null,
|
|
1722
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1723
|
+
"span",
|
|
1724
|
+
{
|
|
1725
|
+
className: "absolute right-0 bottom-0 h-3 w-3 rounded-full bg-black",
|
|
1726
|
+
"aria-hidden": "true"
|
|
1727
|
+
}
|
|
1728
|
+
),
|
|
1729
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1730
|
+
"span",
|
|
1731
|
+
{
|
|
1732
|
+
className: cn(
|
|
1733
|
+
"absolute right-0.5 bottom-0.5 h-2 w-2 rounded-full",
|
|
1734
|
+
statusDotColor,
|
|
1735
|
+
connectionStatus === "connected" && "animate-pulse"
|
|
1736
|
+
),
|
|
1737
|
+
"aria-label": describeStatus(connectionStatus)
|
|
1738
|
+
}
|
|
1739
|
+
)
|
|
1740
|
+
]
|
|
1741
|
+
}
|
|
1742
|
+
),
|
|
1743
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1744
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs tracking-[0.24em] uppercase", children: "Room" }),
|
|
1745
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground text-lg font-semibold", children: typeof window !== "undefined" ? roomId ?? "N/A" : "N/A" })
|
|
1746
|
+
] })
|
|
1747
|
+
] }),
|
|
1748
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pointer-events-auto flex items-center gap-3", children: [
|
|
1749
|
+
customActions,
|
|
1750
|
+
roomId && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1751
|
+
Button,
|
|
1752
|
+
{
|
|
1753
|
+
type: "button",
|
|
1754
|
+
variant: "outline",
|
|
1755
|
+
size: "icon",
|
|
1756
|
+
onClick: () => window.location.reload(),
|
|
1757
|
+
disabled: connectionStatus === "connecting" || connectionStatus === "reconnecting",
|
|
1758
|
+
"aria-label": "Reconnect",
|
|
1759
|
+
title: "Reconnect to room",
|
|
1907
1760
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1908
|
-
|
|
1761
|
+
lucideReact.RefreshCw,
|
|
1909
1762
|
{
|
|
1910
|
-
"data-slot": "slider-range",
|
|
1911
1763
|
className: cn(
|
|
1912
|
-
"
|
|
1764
|
+
"h-5 w-5",
|
|
1765
|
+
(connectionStatus === "connecting" || connectionStatus === "reconnecting") && "animate-spin"
|
|
1913
1766
|
)
|
|
1914
1767
|
}
|
|
1915
1768
|
)
|
|
1916
1769
|
}
|
|
1917
1770
|
),
|
|
1918
|
-
|
|
1919
|
-
|
|
1771
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1772
|
+
Button,
|
|
1920
1773
|
{
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1774
|
+
type: "button",
|
|
1775
|
+
variant: "outline",
|
|
1776
|
+
size: "icon",
|
|
1777
|
+
onClick: () => setIsScannerOpen(true),
|
|
1778
|
+
"aria-label": "Scan QR code to reconnect",
|
|
1779
|
+
title: "Scan QR code to reconnect",
|
|
1780
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.QrCode, { className: "h-5 w-5" })
|
|
1781
|
+
}
|
|
1782
|
+
),
|
|
1783
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1784
|
+
Button,
|
|
1785
|
+
{
|
|
1786
|
+
type: "button",
|
|
1787
|
+
variant: "outline",
|
|
1788
|
+
size: "icon",
|
|
1789
|
+
onClick: () => sendSystemCommand("toggle_pause"),
|
|
1790
|
+
"aria-label": gameState === "playing" ? "Pause" : "Play",
|
|
1791
|
+
title: gameState === "playing" ? "Pause" : "Play",
|
|
1792
|
+
children: gameState === "playing" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, { className: "h-5 w-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "h-5 w-5" })
|
|
1793
|
+
}
|
|
1794
|
+
),
|
|
1795
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1796
|
+
Button,
|
|
1797
|
+
{
|
|
1798
|
+
type: "button",
|
|
1799
|
+
variant: "outline",
|
|
1800
|
+
size: "icon",
|
|
1801
|
+
onClick: () => toggleFullscreen(),
|
|
1802
|
+
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
|
|
1803
|
+
title: isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
|
|
1804
|
+
children: isFullscreen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize, { className: "h-5 w-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize, { className: "h-5 w-5" })
|
|
1805
|
+
}
|
|
1806
|
+
)
|
|
1807
|
+
] })
|
|
1943
1808
|
] }),
|
|
1944
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1945
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-
|
|
1946
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
1947
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1953
|
-
Slider,
|
|
1954
|
-
{
|
|
1955
|
-
value: [masterVolume * 100],
|
|
1956
|
-
onValueChange: (values) => setMasterVolume(values[0] / 100),
|
|
1957
|
-
min: 0,
|
|
1958
|
-
max: 100,
|
|
1959
|
-
step: 1,
|
|
1960
|
-
className: "w-full",
|
|
1961
|
-
"aria-label": "Master volume"
|
|
1962
|
-
}
|
|
1963
|
-
)
|
|
1964
|
-
] }),
|
|
1965
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
1966
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1967
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1968
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Music, { className: "text-muted-foreground h-3 w-3" }),
|
|
1969
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-xs", children: "Music" })
|
|
1970
|
-
] }),
|
|
1971
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
1972
|
-
Math.round(musicVolume * 100),
|
|
1973
|
-
"%"
|
|
1974
|
-
] })
|
|
1975
|
-
] }),
|
|
1976
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1977
|
-
Slider,
|
|
1978
|
-
{
|
|
1979
|
-
value: [musicVolume * 100],
|
|
1980
|
-
onValueChange: (values) => setMusicVolume(values[0] / 100),
|
|
1981
|
-
min: 0,
|
|
1982
|
-
max: 100,
|
|
1983
|
-
step: 1,
|
|
1984
|
-
className: "w-full",
|
|
1985
|
-
"aria-label": "Music volume"
|
|
1986
|
-
}
|
|
1987
|
-
)
|
|
1988
|
-
] }),
|
|
1989
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
1990
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1991
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1992
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headphones, { className: "text-muted-foreground h-3 w-3" }),
|
|
1993
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-xs", children: "SFX" })
|
|
1994
|
-
] }),
|
|
1995
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
1996
|
-
Math.round(sfxVolume * 100),
|
|
1997
|
-
"%"
|
|
1809
|
+
/* @__PURE__ */ jsxRuntime.jsx("main", { className: "relative flex min-h-0 flex-1 items-center justify-center overflow-hidden p-2 select-none sm:p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-card/95 absolute inset-0 z-10 flex flex-col items-center justify-center p-6 text-center shadow-lg backdrop-blur-sm", children: [
|
|
1810
|
+
!orientationOk && forceOrientation && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-background/95 absolute inset-0 z-10 flex flex-col items-center justify-center p-6 text-center shadow-lg backdrop-blur-sm", children: [
|
|
1811
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-card-foreground text-xl font-semibold", children: "Rotate your device" }),
|
|
1812
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground mt-2 text-sm", children: [
|
|
1813
|
+
"This game is best experienced in ",
|
|
1814
|
+
forceOrientation,
|
|
1815
|
+
" ",
|
|
1816
|
+
"orientation."
|
|
1998
1817
|
] })
|
|
1999
1818
|
] }),
|
|
2000
1819
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2001
|
-
|
|
1820
|
+
"div",
|
|
2002
1821
|
{
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
className: "w-full",
|
|
2009
|
-
"aria-label": "SFX volume"
|
|
1822
|
+
className: cn(
|
|
1823
|
+
"h-full w-full select-none",
|
|
1824
|
+
!orientationOk && "pointer-events-none opacity-30"
|
|
1825
|
+
),
|
|
1826
|
+
children
|
|
2010
1827
|
}
|
|
2011
1828
|
)
|
|
2012
|
-
] })
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
const {
|
|
2025
|
-
roomId,
|
|
2026
|
-
joinUrl,
|
|
2027
|
-
connectionStatus,
|
|
2028
|
-
players,
|
|
2029
|
-
lastError,
|
|
2030
|
-
gameState,
|
|
2031
|
-
toggleGameState,
|
|
2032
|
-
isChildMode
|
|
2033
|
-
} = host;
|
|
2034
|
-
const [qrUrl, setQrUrl] = React.useState(null);
|
|
2035
|
-
const [qrError, setQrError] = React.useState(null);
|
|
2036
|
-
const [copied, setCopied] = React.useState(false);
|
|
2037
|
-
const [copiedPlayerId, setCopiedPlayerId] = React.useState(null);
|
|
2038
|
-
React.useEffect(() => {
|
|
2039
|
-
if (isChildMode) return;
|
|
2040
|
-
let mounted = true;
|
|
2041
|
-
QRCode__default.default.toDataURL(joinUrl, {
|
|
2042
|
-
margin: 1,
|
|
2043
|
-
color: {
|
|
2044
|
-
dark: "#0f172a",
|
|
2045
|
-
light: "#ffffff"
|
|
2046
|
-
},
|
|
2047
|
-
width: 320
|
|
2048
|
-
}).then((value) => {
|
|
2049
|
-
if (mounted) {
|
|
2050
|
-
setQrUrl(value);
|
|
2051
|
-
setQrError(null);
|
|
2052
|
-
}
|
|
2053
|
-
}).catch((err) => {
|
|
2054
|
-
if (mounted) {
|
|
2055
|
-
setQrError(err.message);
|
|
2056
|
-
}
|
|
2057
|
-
});
|
|
2058
|
-
return () => {
|
|
2059
|
-
mounted = false;
|
|
2060
|
-
};
|
|
2061
|
-
}, [joinUrl, isChildMode]);
|
|
2062
|
-
const handleCopyUrl = async () => {
|
|
2063
|
-
if (!joinUrl) return;
|
|
2064
|
-
try {
|
|
2065
|
-
await navigator.clipboard.writeText(joinUrl);
|
|
2066
|
-
setCopied(true);
|
|
2067
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2068
|
-
} catch {
|
|
2069
|
-
const textArea = document.createElement("textarea");
|
|
2070
|
-
textArea.value = joinUrl;
|
|
2071
|
-
textArea.style.position = "fixed";
|
|
2072
|
-
textArea.style.opacity = "0";
|
|
2073
|
-
document.body.appendChild(textArea);
|
|
2074
|
-
textArea.select();
|
|
2075
|
-
try {
|
|
2076
|
-
document.execCommand("copy");
|
|
2077
|
-
setCopied(true);
|
|
2078
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2079
|
-
} catch {
|
|
1829
|
+
] }) }),
|
|
1830
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1831
|
+
QRScannerDialog,
|
|
1832
|
+
{
|
|
1833
|
+
isOpen: isScannerOpen,
|
|
1834
|
+
onClose: () => setIsScannerOpen(false),
|
|
1835
|
+
onScan: (roomCode) => {
|
|
1836
|
+
store.getState().setRoomId(roomCode);
|
|
1837
|
+
reconnect();
|
|
1838
|
+
setIsScannerOpen(false);
|
|
1839
|
+
},
|
|
1840
|
+
currentRoomId: roomId
|
|
2080
1841
|
}
|
|
2081
|
-
|
|
1842
|
+
)
|
|
1843
|
+
] }) });
|
|
1844
|
+
};
|
|
1845
|
+
var useAirJamHost = (options = {}) => {
|
|
1846
|
+
const { config, store, getSocket, disconnectSocket, inputManager } = useAirJamContext();
|
|
1847
|
+
const arcadeParams = React.useMemo(() => {
|
|
1848
|
+
if (typeof window === "undefined") return null;
|
|
1849
|
+
const params = new URLSearchParams(window.location.search);
|
|
1850
|
+
const room = params.get("aj_room");
|
|
1851
|
+
const token = params.get("aj_token");
|
|
1852
|
+
if (room && token) {
|
|
1853
|
+
return { room, token };
|
|
2082
1854
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
1855
|
+
return null;
|
|
1856
|
+
}, []);
|
|
1857
|
+
const isChildMode = !!arcadeParams;
|
|
1858
|
+
const shouldConnect = true;
|
|
1859
|
+
const storeRoomId = zustand.useStore(store, (s) => s.roomId);
|
|
1860
|
+
const parsedRoomId = React.useMemo(() => {
|
|
1861
|
+
if (arcadeParams) {
|
|
1862
|
+
return roomCodeSchema.parse(arcadeParams.room.toUpperCase());
|
|
2087
1863
|
}
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
textArea.value = playerId;
|
|
2098
|
-
textArea.style.position = "fixed";
|
|
2099
|
-
textArea.style.opacity = "0";
|
|
2100
|
-
document.body.appendChild(textArea);
|
|
2101
|
-
textArea.select();
|
|
2102
|
-
try {
|
|
2103
|
-
document.execCommand("copy");
|
|
2104
|
-
console.log(`Copied player ID: ${playerId}`);
|
|
2105
|
-
setCopiedPlayerId(playerId);
|
|
2106
|
-
setTimeout(() => setCopiedPlayerId(null), 1e3);
|
|
2107
|
-
} catch {
|
|
1864
|
+
if (storeRoomId) {
|
|
1865
|
+
return roomCodeSchema.parse(storeRoomId.toUpperCase());
|
|
1866
|
+
}
|
|
1867
|
+
if (typeof window !== "undefined") {
|
|
1868
|
+
const params = new URLSearchParams(window.location.search);
|
|
1869
|
+
const paramRoom = params.get("room");
|
|
1870
|
+
if (paramRoom) {
|
|
1871
|
+
const result = roomCodeSchema.safeParse(paramRoom.toUpperCase());
|
|
1872
|
+
if (result.success) return result.data;
|
|
2108
1873
|
}
|
|
2109
|
-
document.body.removeChild(textArea);
|
|
2110
1874
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
switch (connectionStatus) {
|
|
2114
|
-
case "connected":
|
|
2115
|
-
return "default";
|
|
2116
|
-
case "connecting":
|
|
2117
|
-
case "reconnecting":
|
|
2118
|
-
return "secondary";
|
|
2119
|
-
default:
|
|
2120
|
-
return "destructive";
|
|
1875
|
+
if (options.roomId) {
|
|
1876
|
+
return roomCodeSchema.parse(options.roomId.toUpperCase());
|
|
2121
1877
|
}
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground text-lg font-semibold", children: roomId })
|
|
2129
|
-
] }) }),
|
|
2130
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pointer-events-auto flex items-center gap-3", children: [
|
|
2131
|
-
players.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center -space-x-2", children: [
|
|
2132
|
-
players.slice(0, 4).map((player) => /* @__PURE__ */ jsxRuntime.jsx(PlayerAvatar, { player, size: "sm" }, player.id)),
|
|
2133
|
-
players.length > 4 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-background bg-muted flex h-8 w-8 items-center justify-center rounded-full border-2 text-xs font-medium", children: [
|
|
2134
|
-
"+",
|
|
2135
|
-
players.length - 4
|
|
2136
|
-
] })
|
|
2137
|
-
] }),
|
|
2138
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2139
|
-
Button,
|
|
2140
|
-
{
|
|
2141
|
-
type: "button",
|
|
2142
|
-
variant: "ghost",
|
|
2143
|
-
size: "icon",
|
|
2144
|
-
onClick: toggleGameState,
|
|
2145
|
-
"aria-label": gameState === "playing" ? "Pause" : "Play",
|
|
2146
|
-
className: "h-8 w-8",
|
|
2147
|
-
children: gameState === "playing" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "h-4 w-4" })
|
|
2148
|
-
}
|
|
2149
|
-
)
|
|
2150
|
-
] })
|
|
2151
|
-
] }) }) }),
|
|
2152
|
-
gameState === "paused" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none fixed inset-0 z-99998 flex items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-auto w-full max-w-2xl", children: /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "bg-card/20 flex max-h-[85vh] flex-col overflow-hidden border py-0 shadow-lg backdrop-blur-sm", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2153
|
-
Tabs,
|
|
2154
|
-
{
|
|
2155
|
-
defaultValue: isChildMode ? "settings" : "room-code",
|
|
2156
|
-
className: "flex h-full w-full flex-col gap-0",
|
|
2157
|
-
children: [
|
|
2158
|
-
/* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: "border-border grid w-full shrink-0 grid-cols-2 rounded-none border-b bg-transparent p-0", children: [
|
|
2159
|
-
!isChildMode && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2160
|
-
TabsTrigger,
|
|
2161
|
-
{
|
|
2162
|
-
value: "room-code",
|
|
2163
|
-
className: "hover:bg-background/50 data-[state=active]:bg-background/50 flex items-center gap-2 rounded-none border-none bg-transparent",
|
|
2164
|
-
children: [
|
|
2165
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.QrCode, { className: "h-4 w-4" }),
|
|
2166
|
-
"Room Code"
|
|
2167
|
-
]
|
|
2168
|
-
}
|
|
2169
|
-
),
|
|
2170
|
-
isChildMode && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2171
|
-
TabsTrigger,
|
|
2172
|
-
{
|
|
2173
|
-
value: "info",
|
|
2174
|
-
className: "hover:bg-background/50 data-[state=active]:bg-background/50 flex items-center gap-2 rounded-none border-none bg-transparent",
|
|
2175
|
-
children: [
|
|
2176
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MonitorSmartphone, { className: "h-4 w-4" }),
|
|
2177
|
-
"Platform"
|
|
2178
|
-
]
|
|
2179
|
-
}
|
|
2180
|
-
),
|
|
2181
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2182
|
-
TabsTrigger,
|
|
2183
|
-
{
|
|
2184
|
-
value: "settings",
|
|
2185
|
-
className: "hover:bg-background/50 data-[state=active]:bg-background/50 flex items-center gap-2 rounded-none border-none bg-transparent",
|
|
2186
|
-
children: [
|
|
2187
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "h-4 w-4" }),
|
|
2188
|
-
"Settings"
|
|
2189
|
-
]
|
|
2190
|
-
}
|
|
2191
|
-
)
|
|
2192
|
-
] }),
|
|
2193
|
-
!isChildMode && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2194
|
-
TabsContent,
|
|
2195
|
-
{
|
|
2196
|
-
value: "room-code",
|
|
2197
|
-
className: "mt-0 min-h-0 flex-1 overflow-y-auto",
|
|
2198
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-[auto_1fr]", children: [
|
|
2199
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-start gap-4", children: [
|
|
2200
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
2201
|
-
/* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-3xl font-bold tracking-wider", children: roomId }),
|
|
2202
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2203
|
-
Badge,
|
|
2204
|
-
{
|
|
2205
|
-
variant: connectionVariant,
|
|
2206
|
-
className: "w-fit",
|
|
2207
|
-
children: statusCopy[connectionStatus]
|
|
2208
|
-
}
|
|
2209
|
-
)
|
|
2210
|
-
] }),
|
|
2211
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-border bg-card w-48 shrink-0 overflow-hidden rounded-lg border-2 shadow-md", children: qrUrl ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2212
|
-
"img",
|
|
2213
|
-
{
|
|
2214
|
-
src: qrUrl,
|
|
2215
|
-
alt: `Join room ${roomId}`,
|
|
2216
|
-
className: "w-full rounded bg-white"
|
|
2217
|
-
}
|
|
2218
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-48 items-center justify-center text-sm", children: qrError ? `QR failed: ${qrError}` : "Generating QR code\u2026" }) })
|
|
2219
|
-
] }),
|
|
2220
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
2221
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2222
|
-
/* @__PURE__ */ jsxRuntime.jsx(CardDescription, { className: "text-xs tracking-[0.18em] uppercase", children: "Join URL" }),
|
|
2223
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
2224
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2225
|
-
"input",
|
|
2226
|
-
{
|
|
2227
|
-
type: "text",
|
|
2228
|
-
readOnly: true,
|
|
2229
|
-
value: joinUrl,
|
|
2230
|
-
className: "bg-background border-input text-foreground focus:ring-ring flex h-10 w-full rounded-md border px-3 py-2 font-mono text-xs focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
|
|
2231
|
-
}
|
|
2232
|
-
),
|
|
2233
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2234
|
-
Button,
|
|
2235
|
-
{
|
|
2236
|
-
type: "button",
|
|
2237
|
-
variant: "outline",
|
|
2238
|
-
size: "icon",
|
|
2239
|
-
onClick: handleCopyUrl,
|
|
2240
|
-
className: "h-10 shrink-0",
|
|
2241
|
-
"aria-label": "Copy join URL",
|
|
2242
|
-
children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-4 w-4" })
|
|
2243
|
-
}
|
|
2244
|
-
),
|
|
2245
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2246
|
-
Button,
|
|
2247
|
-
{
|
|
2248
|
-
type: "button",
|
|
2249
|
-
variant: "outline",
|
|
2250
|
-
size: "icon",
|
|
2251
|
-
onClick: handleOpenInNewTab,
|
|
2252
|
-
className: "h-10 shrink-0",
|
|
2253
|
-
"aria-label": "Open join URL in new tab",
|
|
2254
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "h-4 w-4" })
|
|
2255
|
-
}
|
|
2256
|
-
)
|
|
2257
|
-
] })
|
|
2258
|
-
] }),
|
|
2259
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: players.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-white", children: "Waiting for controllers to join\u2026" }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2260
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-foreground text-sm font-medium", children: [
|
|
2261
|
-
"Connected Players (",
|
|
2262
|
-
players.length,
|
|
2263
|
-
")"
|
|
2264
|
-
] }),
|
|
2265
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3", children: players.map((player) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2266
|
-
"li",
|
|
2267
|
-
{
|
|
2268
|
-
className: "flex min-w-0 flex-col items-start gap-2",
|
|
2269
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full min-w-0 items-center gap-2", children: [
|
|
2270
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2271
|
-
PlayerAvatar,
|
|
2272
|
-
{
|
|
2273
|
-
player,
|
|
2274
|
-
size: "md"
|
|
2275
|
-
}
|
|
2276
|
-
),
|
|
2277
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 overflow-hidden", children: [
|
|
2278
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-card-foreground truncate text-sm font-medium", children: player.label }),
|
|
2279
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2280
|
-
"div",
|
|
2281
|
-
{
|
|
2282
|
-
onClick: () => handleCopyPlayerId(player.id),
|
|
2283
|
-
className: "text-muted-foreground m-0 inline min-w-0 cursor-pointer truncate border-0 font-mono text-xs transition-colors hover:text-white",
|
|
2284
|
-
title: "Click to copy player ID",
|
|
2285
|
-
children: copiedPlayerId === player.id ? "Copied!" : player.id.slice(0, 8)
|
|
2286
|
-
}
|
|
2287
|
-
)
|
|
2288
|
-
] })
|
|
2289
|
-
] })
|
|
2290
|
-
},
|
|
2291
|
-
player.id
|
|
2292
|
-
)) })
|
|
2293
|
-
] }) }),
|
|
2294
|
-
lastError && /* @__PURE__ */ jsxRuntime.jsx(Alert, { variant: "destructive", className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(AlertDescription, { children: lastError }) }),
|
|
2295
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-auto flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2296
|
-
Button,
|
|
2297
|
-
{
|
|
2298
|
-
type: "button",
|
|
2299
|
-
onClick: toggleGameState,
|
|
2300
|
-
size: "lg",
|
|
2301
|
-
children: [
|
|
2302
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "mr-2 h-5 w-5" }),
|
|
2303
|
-
"Play"
|
|
2304
|
-
]
|
|
2305
|
-
}
|
|
2306
|
-
) })
|
|
2307
|
-
] })
|
|
2308
|
-
] }) })
|
|
2309
|
-
}
|
|
2310
|
-
),
|
|
2311
|
-
isChildMode && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2312
|
-
TabsContent,
|
|
2313
|
-
{
|
|
2314
|
-
value: "info",
|
|
2315
|
-
className: "mt-0 min-h-0 flex-1 overflow-y-auto",
|
|
2316
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
2317
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
2318
|
-
/* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-2xl font-bold tracking-wider", children: "Connected to Platform" }),
|
|
2319
|
-
/* @__PURE__ */ jsxRuntime.jsx(CardDescription, { children: "This game is running inside the Air Jam Platform." })
|
|
2320
|
-
] }),
|
|
2321
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2322
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-foreground text-sm font-medium", children: [
|
|
2323
|
-
"Connected Players (",
|
|
2324
|
-
players.length,
|
|
2325
|
-
")"
|
|
2326
|
-
] }),
|
|
2327
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3", children: players.map((player) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2328
|
-
"li",
|
|
2329
|
-
{
|
|
2330
|
-
className: "flex min-w-0 flex-col items-start gap-2",
|
|
2331
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full min-w-0 items-center gap-2", children: [
|
|
2332
|
-
/* @__PURE__ */ jsxRuntime.jsx(PlayerAvatar, { player, size: "md" }),
|
|
2333
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-card-foreground truncate text-sm font-medium", children: player.label }) })
|
|
2334
|
-
] })
|
|
2335
|
-
},
|
|
2336
|
-
player.id
|
|
2337
|
-
)) })
|
|
2338
|
-
] }),
|
|
2339
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2340
|
-
Button,
|
|
2341
|
-
{
|
|
2342
|
-
type: "button",
|
|
2343
|
-
onClick: toggleGameState,
|
|
2344
|
-
size: "lg",
|
|
2345
|
-
children: [
|
|
2346
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "mr-2 h-5 w-5" }),
|
|
2347
|
-
"Resume Game"
|
|
2348
|
-
]
|
|
2349
|
-
}
|
|
2350
|
-
) })
|
|
2351
|
-
] }) })
|
|
2352
|
-
}
|
|
2353
|
-
),
|
|
2354
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2355
|
-
TabsContent,
|
|
2356
|
-
{
|
|
2357
|
-
value: "settings",
|
|
2358
|
-
className: "mt-0 min-h-0 flex-1 overflow-y-auto",
|
|
2359
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { className: "pt-6 pb-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
2360
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntime.jsx(VolumeControls, {}) }),
|
|
2361
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 border-t pt-4", children: [
|
|
2362
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold", children: "Connection" }),
|
|
2363
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
2364
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2365
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Status" }),
|
|
2366
|
-
/* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: connectionVariant, children: statusCopy[connectionStatus] })
|
|
2367
|
-
] }),
|
|
2368
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2369
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Room ID" }),
|
|
2370
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: roomId })
|
|
2371
|
-
] }),
|
|
2372
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2373
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Players" }),
|
|
2374
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: players.length })
|
|
2375
|
-
] })
|
|
2376
|
-
] })
|
|
2377
|
-
] }),
|
|
2378
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 border-t pt-4", children: [
|
|
2379
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold", children: "Display" }),
|
|
2380
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2381
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Game State" }),
|
|
2382
|
-
/* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", className: "capitalize", children: gameState })
|
|
2383
|
-
] }) })
|
|
2384
|
-
] })
|
|
2385
|
-
] }) })
|
|
2386
|
-
}
|
|
2387
|
-
)
|
|
2388
|
-
]
|
|
2389
|
-
}
|
|
2390
|
-
) }) }) })
|
|
2391
|
-
] });
|
|
2392
|
-
};
|
|
2393
|
-
var useFullscreen = () => {
|
|
2394
|
-
const [isFullscreen, setIsFullscreen] = React.useState(false);
|
|
1878
|
+
return null;
|
|
1879
|
+
}, [options.roomId, storeRoomId, arcadeParams]);
|
|
1880
|
+
const [joinUrl, setJoinUrl] = React.useState("");
|
|
1881
|
+
const onPlayerJoinRef = React.useRef(options.onPlayerJoin);
|
|
1882
|
+
const onPlayerLeaveRef = React.useRef(options.onPlayerLeave);
|
|
1883
|
+
const onChildCloseRef = React.useRef(options.onChildClose);
|
|
2395
1884
|
React.useEffect(() => {
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
};
|
|
2421
|
-
}, []);
|
|
2422
|
-
const exitFullscreen = React.useCallback(async () => {
|
|
2423
|
-
try {
|
|
2424
|
-
const doc = document;
|
|
2425
|
-
if (document.fullscreenElement || doc.webkitFullscreenElement || doc.mozFullScreenElement || doc.msFullscreenElement) {
|
|
2426
|
-
if (document.exitFullscreen) {
|
|
2427
|
-
await document.exitFullscreen();
|
|
2428
|
-
} else if (doc.webkitExitFullscreen) {
|
|
2429
|
-
await doc.webkitExitFullscreen();
|
|
2430
|
-
} else if (doc.mozCancelFullScreen) {
|
|
2431
|
-
await doc.mozCancelFullScreen();
|
|
2432
|
-
} else if (doc.msExitFullscreen) {
|
|
2433
|
-
await doc.msExitFullscreen();
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
} catch (error) {
|
|
2437
|
-
console.error("Error exiting fullscreen:", error);
|
|
1885
|
+
onPlayerJoinRef.current = options.onPlayerJoin;
|
|
1886
|
+
onPlayerLeaveRef.current = options.onPlayerLeave;
|
|
1887
|
+
onChildCloseRef.current = options.onChildClose;
|
|
1888
|
+
}, [options.onPlayerJoin, options.onPlayerLeave, options.onChildClose]);
|
|
1889
|
+
const connectionState = zustand.useStore(
|
|
1890
|
+
store,
|
|
1891
|
+
shallow.useShallow((state) => ({
|
|
1892
|
+
connectionStatus: state.connectionStatus,
|
|
1893
|
+
lastError: state.lastError,
|
|
1894
|
+
players: state.players,
|
|
1895
|
+
gameState: state.gameState,
|
|
1896
|
+
mode: state.mode,
|
|
1897
|
+
roomId: state.roomId
|
|
1898
|
+
}))
|
|
1899
|
+
);
|
|
1900
|
+
const socket = React.useMemo(
|
|
1901
|
+
() => getSocket("host") ,
|
|
1902
|
+
[shouldConnect, getSocket]
|
|
1903
|
+
);
|
|
1904
|
+
const [lastToggle, setLastToggle] = React.useState(0);
|
|
1905
|
+
const toggleGameState = React.useCallback(() => {
|
|
1906
|
+
const now = Date.now();
|
|
1907
|
+
if (now - lastToggle < TOGGLE_DEBOUNCE_MS) {
|
|
1908
|
+
return;
|
|
2438
1909
|
}
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
const elem = element || document.documentElement;
|
|
2443
|
-
if (elem.requestFullscreen) {
|
|
2444
|
-
await elem.requestFullscreen();
|
|
2445
|
-
} else if (elem.webkitRequestFullscreen) {
|
|
2446
|
-
await elem.webkitRequestFullscreen();
|
|
2447
|
-
} else if (elem.mozRequestFullScreen) {
|
|
2448
|
-
await elem.mozRequestFullScreen();
|
|
2449
|
-
} else if (elem.msRequestFullscreen) {
|
|
2450
|
-
await elem.msRequestFullscreen();
|
|
2451
|
-
}
|
|
2452
|
-
} catch (error) {
|
|
2453
|
-
console.error("Error entering fullscreen:", error);
|
|
1910
|
+
setLastToggle(now);
|
|
1911
|
+
if (!socket || !socket.connected) {
|
|
1912
|
+
return;
|
|
2454
1913
|
}
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
1914
|
+
if (!parsedRoomId) return;
|
|
1915
|
+
const payload = controllerSystemSchema.safeParse({
|
|
1916
|
+
roomId: parsedRoomId,
|
|
1917
|
+
command: "toggle_pause"
|
|
1918
|
+
});
|
|
1919
|
+
if (payload.success) {
|
|
1920
|
+
socket.emit("host:system", payload.data);
|
|
1921
|
+
}
|
|
1922
|
+
}, [socket, parsedRoomId, lastToggle]);
|
|
1923
|
+
const sendState = React.useCallback(
|
|
1924
|
+
(state) => {
|
|
1925
|
+
if (!socket || !socket.connected || !parsedRoomId) {
|
|
1926
|
+
return false;
|
|
2462
1927
|
}
|
|
1928
|
+
const payload = controllerStateSchema.safeParse({
|
|
1929
|
+
roomId: parsedRoomId,
|
|
1930
|
+
state
|
|
1931
|
+
});
|
|
1932
|
+
if (!payload.success) {
|
|
1933
|
+
return false;
|
|
1934
|
+
}
|
|
1935
|
+
socket.emit("host:state", payload.data);
|
|
1936
|
+
return true;
|
|
2463
1937
|
},
|
|
2464
|
-
[
|
|
1938
|
+
[socket, parsedRoomId]
|
|
2465
1939
|
);
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
toggleFullscreen
|
|
2471
|
-
};
|
|
2472
|
-
};
|
|
2473
|
-
var extractRoomCode = (text) => {
|
|
2474
|
-
try {
|
|
2475
|
-
const url = new URL(text);
|
|
2476
|
-
const roomParam = url.searchParams.get("room");
|
|
2477
|
-
if (roomParam) {
|
|
2478
|
-
const parsed2 = roomCodeSchema.safeParse(roomParam.toUpperCase());
|
|
2479
|
-
if (parsed2.success) {
|
|
2480
|
-
return parsed2.data;
|
|
1940
|
+
const sendSignal = React.useCallback(
|
|
1941
|
+
(type, payload, targetId) => {
|
|
1942
|
+
if (!socket || !socket.connected) {
|
|
1943
|
+
return;
|
|
2481
1944
|
}
|
|
1945
|
+
const signal = {
|
|
1946
|
+
targetId,
|
|
1947
|
+
type,
|
|
1948
|
+
payload
|
|
1949
|
+
};
|
|
1950
|
+
socket.emit("host:signal", signal);
|
|
1951
|
+
},
|
|
1952
|
+
[socket]
|
|
1953
|
+
);
|
|
1954
|
+
const reconnect = React.useCallback(() => {
|
|
1955
|
+
disconnectSocket("host");
|
|
1956
|
+
if (socket) {
|
|
1957
|
+
socket.connect();
|
|
2482
1958
|
}
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
const parsed = roomCodeSchema.safeParse(text.trim().toUpperCase());
|
|
2486
|
-
if (parsed.success) {
|
|
2487
|
-
return parsed.data;
|
|
2488
|
-
}
|
|
2489
|
-
return null;
|
|
2490
|
-
};
|
|
2491
|
-
var QRScannerDialog = ({
|
|
2492
|
-
isOpen,
|
|
2493
|
-
onClose,
|
|
2494
|
-
onScan,
|
|
2495
|
-
currentRoomId
|
|
2496
|
-
}) => {
|
|
2497
|
-
const [code, setCode] = React.useState("");
|
|
2498
|
-
const [isCameraAvailable, setIsCameraAvailable] = React.useState(false);
|
|
2499
|
-
const [joinUrl, setJoinUrl] = React.useState("");
|
|
2500
|
-
const [copied, setCopied] = React.useState(false);
|
|
2501
|
-
const scannerRef = React.useRef(null);
|
|
2502
|
-
const inputRef = React.useRef(null);
|
|
2503
|
-
const prevIsOpenRef = React.useRef(false);
|
|
2504
|
-
React.useEffect(() => {
|
|
2505
|
-
if (isOpen && !prevIsOpenRef.current) {
|
|
2506
|
-
const initialCode = currentRoomId || "";
|
|
2507
|
-
setTimeout(() => {
|
|
2508
|
-
setIsCameraAvailable(false);
|
|
2509
|
-
setCode(initialCode);
|
|
2510
|
-
inputRef.current?.focus();
|
|
2511
|
-
inputRef.current?.select();
|
|
2512
|
-
}, 0);
|
|
2513
|
-
}
|
|
2514
|
-
prevIsOpenRef.current = isOpen;
|
|
2515
|
-
}, [isOpen, currentRoomId]);
|
|
1959
|
+
}, [socket, disconnectSocket]);
|
|
2516
1960
|
React.useEffect(() => {
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
const
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
}
|
|
2527
|
-
} else {
|
|
2528
|
-
setJoinUrl("");
|
|
2529
|
-
}
|
|
2530
|
-
};
|
|
2531
|
-
buildUrl();
|
|
2532
|
-
}, [code]);
|
|
1961
|
+
if (!parsedRoomId) return;
|
|
1962
|
+
(async () => {
|
|
1963
|
+
const url = await urlBuilder.buildControllerUrl(parsedRoomId, {
|
|
1964
|
+
host: config.publicHost
|
|
1965
|
+
});
|
|
1966
|
+
setJoinUrl(url);
|
|
1967
|
+
})();
|
|
1968
|
+
}, [parsedRoomId, config.publicHost, options.roomId]);
|
|
1969
|
+
const setRegisteredRoomId = zustand.useStore(store, (s) => s.setRegisteredRoomId);
|
|
2533
1970
|
React.useEffect(() => {
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
const scanner = scannerRef.current;
|
|
2540
|
-
scanner.stop().catch(() => {
|
|
2541
|
-
}).finally(() => {
|
|
2542
|
-
try {
|
|
2543
|
-
scanner.clear();
|
|
2544
|
-
} catch {
|
|
2545
|
-
}
|
|
2546
|
-
});
|
|
2547
|
-
scannerRef.current = null;
|
|
2548
|
-
}
|
|
1971
|
+
const storeState = store.getState();
|
|
1972
|
+
storeState.setMode(detectRunMode());
|
|
1973
|
+
storeState.setRole("host");
|
|
1974
|
+
if (parsedRoomId) {
|
|
1975
|
+
storeState.setRoomId(parsedRoomId);
|
|
2549
1976
|
}
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
if (!
|
|
1977
|
+
storeState.setStatus("connecting");
|
|
1978
|
+
storeState.setError(void 0);
|
|
1979
|
+
if (!socket) {
|
|
1980
|
+
storeState.setStatus("idle");
|
|
2553
1981
|
return;
|
|
2554
1982
|
}
|
|
2555
|
-
const
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
const
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
}
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
const backCamera = devices.find(
|
|
2576
|
-
(d) => d.label.toLowerCase().includes("back") || d.label.toLowerCase().includes("rear")
|
|
2577
|
-
);
|
|
2578
|
-
const envCamera = devices.find((d) => {
|
|
2579
|
-
const label = d.label.toLowerCase();
|
|
2580
|
-
return label.includes("environment") || label.includes("facing back");
|
|
2581
|
-
});
|
|
2582
|
-
cameraId = (envCamera || backCamera || devices[0])?.id || null;
|
|
1983
|
+
const registerHost = async () => {
|
|
1984
|
+
const storeState2 = store.getState();
|
|
1985
|
+
const currentRegisteredRoomId2 = store.getState().registeredRoomId;
|
|
1986
|
+
if (currentRegisteredRoomId2 && socket.connected) {
|
|
1987
|
+
return;
|
|
1988
|
+
}
|
|
1989
|
+
if (arcadeParams) {
|
|
1990
|
+
const childRoomId = roomCodeSchema.parse(
|
|
1991
|
+
arcadeParams.room.toUpperCase()
|
|
1992
|
+
);
|
|
1993
|
+
const payload = {
|
|
1994
|
+
roomId: childRoomId,
|
|
1995
|
+
joinToken: arcadeParams.token
|
|
1996
|
+
};
|
|
1997
|
+
socket.emit("host:joinAsChild", payload, (ack) => {
|
|
1998
|
+
if (!ack.ok) {
|
|
1999
|
+
storeState2.setError(ack.message ?? "Failed to join as child");
|
|
2000
|
+
storeState2.setStatus("disconnected");
|
|
2001
|
+
setRegisteredRoomId(null);
|
|
2002
|
+
return;
|
|
2583
2003
|
}
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
},
|
|
2601
|
-
(decodedText) => {
|
|
2602
|
-
if (!mounted) return;
|
|
2603
|
-
const roomCode = extractRoomCode(decodedText);
|
|
2604
|
-
if (roomCode) {
|
|
2605
|
-
setCode(roomCode);
|
|
2606
|
-
scannerRunning = false;
|
|
2607
|
-
scanner?.stop().catch(() => {
|
|
2608
|
-
}).finally(() => {
|
|
2609
|
-
if (mounted) {
|
|
2610
|
-
setIsCameraAvailable(false);
|
|
2611
|
-
}
|
|
2612
|
-
});
|
|
2004
|
+
storeState2.setStatus("connected");
|
|
2005
|
+
storeState2.setRoomId(childRoomId);
|
|
2006
|
+
setRegisteredRoomId(childRoomId);
|
|
2007
|
+
});
|
|
2008
|
+
} else {
|
|
2009
|
+
const createNewRoom = () => {
|
|
2010
|
+
const payload = hostCreateRoomSchema.parse({
|
|
2011
|
+
maxPlayers: options.maxPlayers ?? config.maxPlayers,
|
|
2012
|
+
apiKey: options.apiKey ?? config.apiKey
|
|
2013
|
+
});
|
|
2014
|
+
socket.emit("host:createRoom", payload, (ack) => {
|
|
2015
|
+
if (!ack.ok) {
|
|
2016
|
+
storeState2.setError(ack.message ?? "Failed to create room");
|
|
2017
|
+
storeState2.setStatus("disconnected");
|
|
2018
|
+
setRegisteredRoomId(null);
|
|
2019
|
+
return;
|
|
2613
2020
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2021
|
+
if (ack.roomId) {
|
|
2022
|
+
storeState2.setStatus("connected");
|
|
2023
|
+
storeState2.setRoomId(ack.roomId);
|
|
2024
|
+
setRegisteredRoomId(ack.roomId);
|
|
2025
|
+
if (typeof window !== "undefined") {
|
|
2026
|
+
sessionStorage.setItem("airjam_room_id", ack.roomId);
|
|
2027
|
+
}
|
|
2028
|
+
} else {
|
|
2029
|
+
storeState2.setError("Server did not return room ID");
|
|
2030
|
+
storeState2.setStatus("disconnected");
|
|
2031
|
+
}
|
|
2032
|
+
});
|
|
2033
|
+
};
|
|
2034
|
+
if (typeof window !== "undefined") {
|
|
2035
|
+
const savedRoomId = sessionStorage.getItem("airjam_room_id");
|
|
2036
|
+
if (savedRoomId) {
|
|
2037
|
+
const reconnectPayload = hostReconnectSchema.parse({
|
|
2038
|
+
roomId: savedRoomId,
|
|
2039
|
+
apiKey: options.apiKey ?? config.apiKey
|
|
2040
|
+
});
|
|
2041
|
+
socket.emit("host:reconnect", reconnectPayload, (ack) => {
|
|
2042
|
+
if (ack.ok && ack.roomId) {
|
|
2043
|
+
storeState2.setStatus("connected");
|
|
2044
|
+
storeState2.setRoomId(ack.roomId);
|
|
2045
|
+
setRegisteredRoomId(ack.roomId);
|
|
2046
|
+
} else {
|
|
2047
|
+
if (typeof window !== "undefined") {
|
|
2048
|
+
sessionStorage.removeItem("airjam_room_id");
|
|
2049
|
+
}
|
|
2050
|
+
createNewRoom();
|
|
2051
|
+
}
|
|
2052
|
+
});
|
|
2053
|
+
} else {
|
|
2054
|
+
createNewRoom();
|
|
2630
2055
|
}
|
|
2056
|
+
} else {
|
|
2057
|
+
createNewRoom();
|
|
2631
2058
|
}
|
|
2632
|
-
scannerRef.current = null;
|
|
2633
2059
|
}
|
|
2634
2060
|
};
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2061
|
+
const handleConnect = () => {
|
|
2062
|
+
store.getState().setStatus("connected");
|
|
2063
|
+
registerHost();
|
|
2064
|
+
};
|
|
2065
|
+
const handleDisconnect = () => {
|
|
2066
|
+
store.getState().setStatus("disconnected");
|
|
2067
|
+
};
|
|
2068
|
+
const handleJoin = (payload) => {
|
|
2069
|
+
if (payload.player) {
|
|
2070
|
+
store.getState().upsertPlayer(payload.player);
|
|
2071
|
+
setTimeout(() => {
|
|
2072
|
+
onPlayerJoinRef.current?.(payload.player);
|
|
2073
|
+
}, 0);
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
const handleLeave = (payload) => {
|
|
2077
|
+
store.getState().removePlayer(payload.controllerId);
|
|
2078
|
+
onPlayerLeaveRef.current?.(payload.controllerId);
|
|
2079
|
+
};
|
|
2080
|
+
const handleInput = (payload) => {
|
|
2081
|
+
if (inputManager) {
|
|
2082
|
+
inputManager.handleInput(payload);
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
2085
|
+
const handleChildClose = () => {
|
|
2086
|
+
onChildCloseRef.current?.();
|
|
2087
|
+
};
|
|
2088
|
+
const handleState = (payload) => {
|
|
2089
|
+
if (!parsedRoomId || payload.roomId !== parsedRoomId) return;
|
|
2090
|
+
const storeState2 = store.getState();
|
|
2091
|
+
if (payload.state.gameState) {
|
|
2092
|
+
storeState2.setGameState(payload.state.gameState);
|
|
2093
|
+
}
|
|
2094
|
+
if (payload.state.message !== void 0) {
|
|
2095
|
+
storeState2.setStateMessage(payload.state.message);
|
|
2654
2096
|
}
|
|
2655
|
-
scannerRef.current = null;
|
|
2656
2097
|
};
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2098
|
+
const handleError = (payload) => {
|
|
2099
|
+
store.getState().setError(payload.message);
|
|
2100
|
+
};
|
|
2101
|
+
socket.on("connect", handleConnect);
|
|
2102
|
+
socket.on("disconnect", handleDisconnect);
|
|
2103
|
+
socket.on("server:controllerJoined", handleJoin);
|
|
2104
|
+
socket.on("server:controllerLeft", handleLeave);
|
|
2105
|
+
socket.on("server:input", handleInput);
|
|
2106
|
+
socket.on("server:error", handleError);
|
|
2107
|
+
socket.on("server:closeChild", handleChildClose);
|
|
2108
|
+
socket.on("server:state", handleState);
|
|
2109
|
+
socket.connect();
|
|
2110
|
+
const currentRegisteredRoomId = store.getState().registeredRoomId;
|
|
2111
|
+
if (socket.connected && !currentRegisteredRoomId) {
|
|
2112
|
+
registerHost();
|
|
2664
2113
|
}
|
|
2114
|
+
return () => {
|
|
2115
|
+
socket.off("connect", handleConnect);
|
|
2116
|
+
socket.off("disconnect", handleDisconnect);
|
|
2117
|
+
socket.off("server:controllerJoined", handleJoin);
|
|
2118
|
+
socket.off("server:controllerLeft", handleLeave);
|
|
2119
|
+
socket.off("server:input", handleInput);
|
|
2120
|
+
socket.off("server:error", handleError);
|
|
2121
|
+
socket.off("server:closeChild", handleChildClose);
|
|
2122
|
+
socket.off("server:state", handleState);
|
|
2123
|
+
};
|
|
2124
|
+
}, [
|
|
2125
|
+
config.maxPlayers,
|
|
2126
|
+
config.apiKey,
|
|
2127
|
+
options.maxPlayers,
|
|
2128
|
+
options.apiKey,
|
|
2129
|
+
arcadeParams,
|
|
2130
|
+
parsedRoomId,
|
|
2131
|
+
// Include parsedRoomId since it's used in handleState callback
|
|
2132
|
+
shouldConnect,
|
|
2133
|
+
socket,
|
|
2134
|
+
store,
|
|
2135
|
+
inputManager,
|
|
2136
|
+
setRegisteredRoomId
|
|
2137
|
+
]);
|
|
2138
|
+
const returnSocket = socket ?? getSocket("host");
|
|
2139
|
+
const getInput = React.useCallback(
|
|
2140
|
+
(controllerId) => {
|
|
2141
|
+
if (!inputManager) {
|
|
2142
|
+
return void 0;
|
|
2143
|
+
}
|
|
2144
|
+
return inputManager.getInput(controllerId);
|
|
2145
|
+
},
|
|
2146
|
+
[inputManager]
|
|
2147
|
+
);
|
|
2148
|
+
return {
|
|
2149
|
+
roomId: parsedRoomId ?? "",
|
|
2150
|
+
// Return empty string as fallback if not yet available
|
|
2151
|
+
joinUrl,
|
|
2152
|
+
connectionStatus: connectionState.connectionStatus,
|
|
2153
|
+
players: connectionState.players,
|
|
2154
|
+
lastError: connectionState.lastError,
|
|
2155
|
+
mode: connectionState.mode,
|
|
2156
|
+
gameState: connectionState.gameState,
|
|
2157
|
+
toggleGameState,
|
|
2158
|
+
sendState,
|
|
2159
|
+
sendSignal,
|
|
2160
|
+
reconnect,
|
|
2161
|
+
socket: returnSocket,
|
|
2162
|
+
isChildMode,
|
|
2163
|
+
getInput
|
|
2665
2164
|
};
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
if (!joinUrl) return;
|
|
2675
|
-
try {
|
|
2676
|
-
await navigator.clipboard.writeText(joinUrl);
|
|
2677
|
-
setCopied(true);
|
|
2678
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2679
|
-
} catch {
|
|
2680
|
-
const textArea = document.createElement("textarea");
|
|
2681
|
-
textArea.value = joinUrl;
|
|
2682
|
-
textArea.style.position = "fixed";
|
|
2683
|
-
textArea.style.opacity = "0";
|
|
2684
|
-
document.body.appendChild(textArea);
|
|
2685
|
-
textArea.select();
|
|
2686
|
-
try {
|
|
2687
|
-
document.execCommand("copy");
|
|
2688
|
-
setCopied(true);
|
|
2689
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2690
|
-
} catch {
|
|
2165
|
+
};
|
|
2166
|
+
var alertVariants = classVarianceAuthority.cva(
|
|
2167
|
+
"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
|
2168
|
+
{
|
|
2169
|
+
variants: {
|
|
2170
|
+
variant: {
|
|
2171
|
+
default: "bg-card text-card-foreground",
|
|
2172
|
+
destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"
|
|
2691
2173
|
}
|
|
2692
|
-
|
|
2174
|
+
},
|
|
2175
|
+
defaultVariants: {
|
|
2176
|
+
variant: "default"
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
);
|
|
2180
|
+
function Alert({
|
|
2181
|
+
className,
|
|
2182
|
+
variant,
|
|
2183
|
+
...props
|
|
2184
|
+
}) {
|
|
2185
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2186
|
+
"div",
|
|
2187
|
+
{
|
|
2188
|
+
"data-slot": "alert",
|
|
2189
|
+
role: "alert",
|
|
2190
|
+
className: cn(alertVariants({ variant }), className),
|
|
2191
|
+
...props
|
|
2192
|
+
}
|
|
2193
|
+
);
|
|
2194
|
+
}
|
|
2195
|
+
function AlertDescription({
|
|
2196
|
+
className,
|
|
2197
|
+
...props
|
|
2198
|
+
}) {
|
|
2199
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2200
|
+
"div",
|
|
2201
|
+
{
|
|
2202
|
+
"data-slot": "alert-description",
|
|
2203
|
+
className: cn(
|
|
2204
|
+
"text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
|
|
2205
|
+
className
|
|
2206
|
+
),
|
|
2207
|
+
...props
|
|
2208
|
+
}
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
var badgeVariants = classVarianceAuthority.cva(
|
|
2212
|
+
"inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
|
2213
|
+
{
|
|
2214
|
+
variants: {
|
|
2215
|
+
variant: {
|
|
2216
|
+
default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
2217
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
2218
|
+
destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
2219
|
+
outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"
|
|
2220
|
+
}
|
|
2221
|
+
},
|
|
2222
|
+
defaultVariants: {
|
|
2223
|
+
variant: "default"
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
);
|
|
2227
|
+
function Badge({
|
|
2228
|
+
className,
|
|
2229
|
+
variant,
|
|
2230
|
+
asChild = false,
|
|
2231
|
+
...props
|
|
2232
|
+
}) {
|
|
2233
|
+
const Comp = asChild ? reactSlot.Slot : "span";
|
|
2234
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2235
|
+
Comp,
|
|
2236
|
+
{
|
|
2237
|
+
"data-slot": "badge",
|
|
2238
|
+
className: cn(badgeVariants({ variant }), className),
|
|
2239
|
+
...props
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
function Card({ className, ...props }) {
|
|
2244
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2245
|
+
"div",
|
|
2246
|
+
{
|
|
2247
|
+
"data-slot": "card",
|
|
2248
|
+
className: cn(
|
|
2249
|
+
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
|
|
2250
|
+
className
|
|
2251
|
+
),
|
|
2252
|
+
...props
|
|
2253
|
+
}
|
|
2254
|
+
);
|
|
2255
|
+
}
|
|
2256
|
+
function CardTitle({ className, ...props }) {
|
|
2257
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2258
|
+
"div",
|
|
2259
|
+
{
|
|
2260
|
+
"data-slot": "card-title",
|
|
2261
|
+
className: cn("leading-none font-semibold", className),
|
|
2262
|
+
...props
|
|
2263
|
+
}
|
|
2264
|
+
);
|
|
2265
|
+
}
|
|
2266
|
+
function CardDescription({ className, ...props }) {
|
|
2267
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2268
|
+
"div",
|
|
2269
|
+
{
|
|
2270
|
+
"data-slot": "card-description",
|
|
2271
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
2272
|
+
...props
|
|
2273
|
+
}
|
|
2274
|
+
);
|
|
2275
|
+
}
|
|
2276
|
+
function CardContent({ className, ...props }) {
|
|
2277
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2278
|
+
"div",
|
|
2279
|
+
{
|
|
2280
|
+
"data-slot": "card-content",
|
|
2281
|
+
className: cn("px-6", className),
|
|
2282
|
+
...props
|
|
2283
|
+
}
|
|
2284
|
+
);
|
|
2285
|
+
}
|
|
2286
|
+
function Tabs({
|
|
2287
|
+
className,
|
|
2288
|
+
...props
|
|
2289
|
+
}) {
|
|
2290
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2291
|
+
TabsPrimitive__namespace.Root,
|
|
2292
|
+
{
|
|
2293
|
+
"data-slot": "tabs",
|
|
2294
|
+
className: cn("flex flex-col gap-2", className),
|
|
2295
|
+
...props
|
|
2296
|
+
}
|
|
2297
|
+
);
|
|
2298
|
+
}
|
|
2299
|
+
function TabsList({
|
|
2300
|
+
className,
|
|
2301
|
+
...props
|
|
2302
|
+
}) {
|
|
2303
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2304
|
+
TabsPrimitive__namespace.List,
|
|
2305
|
+
{
|
|
2306
|
+
"data-slot": "tabs-list",
|
|
2307
|
+
className: cn(
|
|
2308
|
+
"bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
|
|
2309
|
+
className
|
|
2310
|
+
),
|
|
2311
|
+
...props
|
|
2312
|
+
}
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
function TabsTrigger({
|
|
2316
|
+
className,
|
|
2317
|
+
...props
|
|
2318
|
+
}) {
|
|
2319
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2320
|
+
TabsPrimitive__namespace.Trigger,
|
|
2321
|
+
{
|
|
2322
|
+
"data-slot": "tabs-trigger",
|
|
2323
|
+
className: cn(
|
|
2324
|
+
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
2325
|
+
className
|
|
2326
|
+
),
|
|
2327
|
+
...props
|
|
2693
2328
|
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2331
|
+
function TabsContent({
|
|
2332
|
+
className,
|
|
2333
|
+
...props
|
|
2334
|
+
}) {
|
|
2335
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2336
|
+
TabsPrimitive__namespace.Content,
|
|
2337
|
+
{
|
|
2338
|
+
"data-slot": "tabs-content",
|
|
2339
|
+
className: cn("flex-1 outline-none", className),
|
|
2340
|
+
...props
|
|
2341
|
+
}
|
|
2342
|
+
);
|
|
2343
|
+
}
|
|
2344
|
+
function Slider({
|
|
2345
|
+
className,
|
|
2346
|
+
defaultValue,
|
|
2347
|
+
value,
|
|
2348
|
+
min = 0,
|
|
2349
|
+
max = 100,
|
|
2350
|
+
...props
|
|
2351
|
+
}) {
|
|
2352
|
+
const _values = React__namespace.useMemo(
|
|
2353
|
+
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
2354
|
+
[value, defaultValue, min, max]
|
|
2355
|
+
);
|
|
2356
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2357
|
+
SliderPrimitive__namespace.Root,
|
|
2358
|
+
{
|
|
2359
|
+
"data-slot": "slider",
|
|
2360
|
+
defaultValue,
|
|
2361
|
+
value,
|
|
2362
|
+
min,
|
|
2363
|
+
max,
|
|
2364
|
+
className: cn(
|
|
2365
|
+
"relative flex w-full cursor-pointer touch-none items-center select-none data-disabled:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
2366
|
+
className
|
|
2367
|
+
),
|
|
2368
|
+
...props,
|
|
2369
|
+
children: [
|
|
2370
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2371
|
+
SliderPrimitive__namespace.Track,
|
|
2372
|
+
{
|
|
2373
|
+
"data-slot": "slider-track",
|
|
2374
|
+
className: cn(
|
|
2375
|
+
"bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
2376
|
+
),
|
|
2377
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2378
|
+
SliderPrimitive__namespace.Range,
|
|
2379
|
+
{
|
|
2380
|
+
"data-slot": "slider-range",
|
|
2381
|
+
className: cn(
|
|
2382
|
+
"bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
|
|
2383
|
+
)
|
|
2384
|
+
}
|
|
2385
|
+
)
|
|
2386
|
+
}
|
|
2387
|
+
),
|
|
2388
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2389
|
+
SliderPrimitive__namespace.Thumb,
|
|
2390
|
+
{
|
|
2391
|
+
"data-slot": "slider-thumb",
|
|
2392
|
+
className: "border-primary ring-ring/50 block size-4 shrink-0 cursor-pointer rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
2720
2393
|
},
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2394
|
+
index
|
|
2395
|
+
))
|
|
2396
|
+
]
|
|
2397
|
+
}
|
|
2398
|
+
);
|
|
2399
|
+
}
|
|
2400
|
+
function VolumeControls({ className, compact }) {
|
|
2401
|
+
const {
|
|
2402
|
+
masterVolume,
|
|
2403
|
+
musicVolume,
|
|
2404
|
+
sfxVolume,
|
|
2405
|
+
setMasterVolume,
|
|
2406
|
+
setMusicVolume,
|
|
2407
|
+
setSfxVolume
|
|
2408
|
+
} = useVolumeStore();
|
|
2409
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-3", compact && "gap-1", className), children: [
|
|
2410
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2411
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { className: "text-muted-foreground h-4 w-4" }),
|
|
2412
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Volume" })
|
|
2413
|
+
] }),
|
|
2414
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
2415
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2416
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-xs", children: "Master" }),
|
|
2417
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2418
|
+
Math.round(masterVolume * 100),
|
|
2419
|
+
"%"
|
|
2420
|
+
] })
|
|
2421
|
+
] }),
|
|
2422
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2423
|
+
Slider,
|
|
2729
2424
|
{
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2425
|
+
value: [masterVolume * 100],
|
|
2426
|
+
onValueChange: (values) => setMasterVolume(values[0] / 100),
|
|
2427
|
+
min: 0,
|
|
2428
|
+
max: 100,
|
|
2429
|
+
step: 1,
|
|
2430
|
+
className: "w-full",
|
|
2431
|
+
"aria-label": "Master volume"
|
|
2734
2432
|
}
|
|
2735
|
-
)
|
|
2433
|
+
)
|
|
2736
2434
|
] }),
|
|
2737
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
2435
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
2436
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2437
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2438
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Music, { className: "text-muted-foreground h-3 w-3" }),
|
|
2439
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-xs", children: "Music" })
|
|
2440
|
+
] }),
|
|
2441
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2442
|
+
Math.round(musicVolume * 100),
|
|
2443
|
+
"%"
|
|
2444
|
+
] })
|
|
2445
|
+
] }),
|
|
2738
2446
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2739
|
-
|
|
2447
|
+
Slider,
|
|
2740
2448
|
{
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2449
|
+
value: [musicVolume * 100],
|
|
2450
|
+
onValueChange: (values) => setMusicVolume(values[0] / 100),
|
|
2451
|
+
min: 0,
|
|
2452
|
+
max: 100,
|
|
2453
|
+
step: 1,
|
|
2454
|
+
className: "w-full",
|
|
2455
|
+
"aria-label": "Music volume"
|
|
2746
2456
|
}
|
|
2747
|
-
)
|
|
2457
|
+
)
|
|
2458
|
+
] }),
|
|
2459
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
2460
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2461
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2462
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headphones, { className: "text-muted-foreground h-3 w-3" }),
|
|
2463
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-muted-foreground text-xs", children: "SFX" })
|
|
2464
|
+
] }),
|
|
2465
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2466
|
+
Math.round(sfxVolume * 100),
|
|
2467
|
+
"%"
|
|
2468
|
+
] })
|
|
2469
|
+
] }),
|
|
2748
2470
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2749
|
-
|
|
2471
|
+
Slider,
|
|
2750
2472
|
{
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2473
|
+
value: [sfxVolume * 100],
|
|
2474
|
+
onValueChange: (values) => setSfxVolume(values[0] / 100),
|
|
2475
|
+
min: 0,
|
|
2476
|
+
max: 100,
|
|
2477
|
+
step: 1,
|
|
2478
|
+
className: "w-full",
|
|
2479
|
+
"aria-label": "SFX volume"
|
|
2756
2480
|
}
|
|
2757
2481
|
)
|
|
2758
2482
|
] })
|
|
2759
2483
|
] });
|
|
2484
|
+
}
|
|
2485
|
+
var statusCopy = {
|
|
2486
|
+
idle: "Idle",
|
|
2487
|
+
connecting: "Waiting for server\u2026",
|
|
2488
|
+
connected: "Ready for controllers",
|
|
2489
|
+
disconnected: "Disconnected",
|
|
2490
|
+
reconnecting: "Reconnecting\u2026"
|
|
2760
2491
|
};
|
|
2761
|
-
var
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
if (!required) return true;
|
|
2778
|
-
if (typeof window === "undefined" || !window.matchMedia) return true;
|
|
2779
|
-
const matcher = window.matchMedia(`(orientation: ${required})`);
|
|
2780
|
-
return matcher.matches;
|
|
2781
|
-
};
|
|
2782
|
-
var ControllerShell = ({
|
|
2783
|
-
roomId,
|
|
2784
|
-
connectionStatus,
|
|
2785
|
-
forceOrientation,
|
|
2786
|
-
children,
|
|
2787
|
-
gameState = "paused",
|
|
2788
|
-
onTogglePlayPause,
|
|
2789
|
-
onReconnect,
|
|
2790
|
-
onRefresh,
|
|
2791
|
-
customActions
|
|
2792
|
-
}) => {
|
|
2793
|
-
const isChildMode = React.useMemo(() => detectRunMode() === "platform", []);
|
|
2794
|
-
const [isOrientationOk, setOrientationOk] = React.useState(
|
|
2795
|
-
() => orientationMatches(forceOrientation)
|
|
2796
|
-
);
|
|
2797
|
-
const [isScannerOpen, setIsScannerOpen] = React.useState(false);
|
|
2798
|
-
const { isFullscreen, toggleFullscreen } = useFullscreen();
|
|
2799
|
-
const { store } = useAirJamContext();
|
|
2800
|
-
const { controllerId, players } = zustand.useStore(
|
|
2801
|
-
store,
|
|
2802
|
-
shallow.useShallow(
|
|
2803
|
-
(state) => ({
|
|
2804
|
-
controllerId: state.controllerId,
|
|
2805
|
-
players: state.players
|
|
2806
|
-
})
|
|
2807
|
-
)
|
|
2808
|
-
);
|
|
2809
|
-
const currentPlayer = React.useMemo(() => {
|
|
2810
|
-
if (!controllerId) return null;
|
|
2811
|
-
const found = players.find((p) => p.id === controllerId);
|
|
2812
|
-
if (!found && connectionStatus === "connected" && players.length > 0) ;
|
|
2813
|
-
return found || null;
|
|
2814
|
-
}, [controllerId, players, connectionStatus]);
|
|
2492
|
+
var HostShell = ({ children }) => {
|
|
2493
|
+
const host = useAirJamHost();
|
|
2494
|
+
const {
|
|
2495
|
+
roomId,
|
|
2496
|
+
joinUrl,
|
|
2497
|
+
connectionStatus,
|
|
2498
|
+
players,
|
|
2499
|
+
lastError,
|
|
2500
|
+
gameState,
|
|
2501
|
+
toggleGameState,
|
|
2502
|
+
isChildMode
|
|
2503
|
+
} = host;
|
|
2504
|
+
const [qrUrl, setQrUrl] = React.useState(null);
|
|
2505
|
+
const [qrError, setQrError] = React.useState(null);
|
|
2506
|
+
const [copied, setCopied] = React.useState(false);
|
|
2507
|
+
const [copiedPlayerId, setCopiedPlayerId] = React.useState(null);
|
|
2815
2508
|
React.useEffect(() => {
|
|
2816
|
-
if (
|
|
2817
|
-
|
|
2818
|
-
|
|
2509
|
+
if (isChildMode) return;
|
|
2510
|
+
let mounted = true;
|
|
2511
|
+
QRCode__default.default.toDataURL(joinUrl, {
|
|
2512
|
+
margin: 1,
|
|
2513
|
+
color: {
|
|
2514
|
+
dark: "#0f172a",
|
|
2515
|
+
light: "#ffffff"
|
|
2516
|
+
},
|
|
2517
|
+
width: 320
|
|
2518
|
+
}).then((value) => {
|
|
2519
|
+
if (mounted) {
|
|
2520
|
+
setQrUrl(value);
|
|
2521
|
+
setQrError(null);
|
|
2522
|
+
}
|
|
2523
|
+
}).catch((err) => {
|
|
2524
|
+
if (mounted) {
|
|
2525
|
+
setQrError(err.message);
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
return () => {
|
|
2529
|
+
mounted = false;
|
|
2530
|
+
};
|
|
2531
|
+
}, [joinUrl, isChildMode]);
|
|
2532
|
+
const handleCopyUrl = async () => {
|
|
2533
|
+
if (!joinUrl) return;
|
|
2534
|
+
try {
|
|
2535
|
+
await navigator.clipboard.writeText(joinUrl);
|
|
2536
|
+
setCopied(true);
|
|
2537
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2538
|
+
} catch {
|
|
2539
|
+
const textArea = document.createElement("textarea");
|
|
2540
|
+
textArea.value = joinUrl;
|
|
2541
|
+
textArea.style.position = "fixed";
|
|
2542
|
+
textArea.style.opacity = "0";
|
|
2543
|
+
document.body.appendChild(textArea);
|
|
2544
|
+
textArea.select();
|
|
2545
|
+
try {
|
|
2546
|
+
document.execCommand("copy");
|
|
2547
|
+
setCopied(true);
|
|
2548
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2549
|
+
} catch {
|
|
2550
|
+
}
|
|
2551
|
+
document.body.removeChild(textArea);
|
|
2819
2552
|
}
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
}
|
|
2826
|
-
const
|
|
2827
|
-
|
|
2553
|
+
};
|
|
2554
|
+
const handleOpenInNewTab = () => {
|
|
2555
|
+
if (joinUrl) {
|
|
2556
|
+
window.open(joinUrl, "_blank", "noopener,noreferrer");
|
|
2557
|
+
}
|
|
2558
|
+
};
|
|
2559
|
+
const handleCopyPlayerId = async (playerId) => {
|
|
2560
|
+
try {
|
|
2561
|
+
await navigator.clipboard.writeText(playerId);
|
|
2562
|
+
console.log(`Copied player ID: ${playerId}`);
|
|
2563
|
+
setCopiedPlayerId(playerId);
|
|
2564
|
+
setTimeout(() => setCopiedPlayerId(null), 1e3);
|
|
2565
|
+
} catch {
|
|
2566
|
+
const textArea = document.createElement("textarea");
|
|
2567
|
+
textArea.value = playerId;
|
|
2568
|
+
textArea.style.position = "fixed";
|
|
2569
|
+
textArea.style.opacity = "0";
|
|
2570
|
+
document.body.appendChild(textArea);
|
|
2571
|
+
textArea.select();
|
|
2572
|
+
try {
|
|
2573
|
+
document.execCommand("copy");
|
|
2574
|
+
console.log(`Copied player ID: ${playerId}`);
|
|
2575
|
+
setCopiedPlayerId(playerId);
|
|
2576
|
+
setTimeout(() => setCopiedPlayerId(null), 1e3);
|
|
2577
|
+
} catch {
|
|
2578
|
+
}
|
|
2579
|
+
document.body.removeChild(textArea);
|
|
2580
|
+
}
|
|
2581
|
+
};
|
|
2582
|
+
const connectionVariant = React.useMemo(() => {
|
|
2828
2583
|
switch (connectionStatus) {
|
|
2829
2584
|
case "connected":
|
|
2830
|
-
return "
|
|
2585
|
+
return "default";
|
|
2831
2586
|
case "connecting":
|
|
2832
2587
|
case "reconnecting":
|
|
2833
|
-
return "
|
|
2834
|
-
case "disconnected":
|
|
2588
|
+
return "secondary";
|
|
2835
2589
|
default:
|
|
2836
|
-
return "
|
|
2590
|
+
return "destructive";
|
|
2837
2591
|
}
|
|
2838
2592
|
}, [connectionStatus]);
|
|
2839
2593
|
if (isChildMode) {
|
|
2840
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2594
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
2595
|
+
}
|
|
2596
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dark relative", children: [
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute inset-x-0 top-0 z-99999", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
2598
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2599
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs tracking-[0.18em] uppercase", children: "Room" }),
|
|
2600
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground text-lg font-semibold", children: roomId })
|
|
2601
|
+
] }) }),
|
|
2602
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pointer-events-auto flex items-center gap-3", children: [
|
|
2603
|
+
players.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center -space-x-2", children: [
|
|
2604
|
+
players.slice(0, 4).map((player) => /* @__PURE__ */ jsxRuntime.jsx(PlayerAvatar, { player, size: "sm" }, player.id)),
|
|
2605
|
+
players.length > 4 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-background bg-muted flex h-8 w-8 items-center justify-center rounded-full border-2 text-xs font-medium", children: [
|
|
2606
|
+
"+",
|
|
2607
|
+
players.length - 4
|
|
2608
|
+
] })
|
|
2609
|
+
] }),
|
|
2610
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2611
|
+
Button,
|
|
2612
|
+
{
|
|
2613
|
+
type: "button",
|
|
2614
|
+
variant: "ghost",
|
|
2615
|
+
size: "icon",
|
|
2616
|
+
onClick: toggleGameState,
|
|
2617
|
+
"aria-label": gameState === "playing" ? "Pause" : "Play",
|
|
2618
|
+
className: "h-8 w-8",
|
|
2619
|
+
children: gameState === "playing" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "h-4 w-4" })
|
|
2620
|
+
}
|
|
2621
|
+
)
|
|
2622
|
+
] })
|
|
2623
|
+
] }) }) }),
|
|
2624
|
+
gameState === "paused" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none fixed inset-0 z-99998 flex items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-auto w-full max-w-2xl", children: /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "bg-card/20 flex max-h-[85vh] flex-col overflow-hidden border py-0 shadow-lg backdrop-blur-sm", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2625
|
+
Tabs,
|
|
2626
|
+
{
|
|
2627
|
+
defaultValue: isChildMode ? "settings" : "room-code",
|
|
2628
|
+
className: "flex h-full w-full flex-col gap-0",
|
|
2629
|
+
children: [
|
|
2630
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: "border-border grid w-full shrink-0 grid-cols-2 rounded-none border-b bg-transparent p-0", children: [
|
|
2631
|
+
!isChildMode && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2632
|
+
TabsTrigger,
|
|
2633
|
+
{
|
|
2634
|
+
value: "room-code",
|
|
2635
|
+
className: "hover:bg-background/50 data-[state=active]:bg-background/50 flex items-center gap-2 rounded-none border-none bg-transparent",
|
|
2636
|
+
children: [
|
|
2637
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.QrCode, { className: "h-4 w-4" }),
|
|
2638
|
+
"Room Code"
|
|
2639
|
+
]
|
|
2640
|
+
}
|
|
2641
|
+
),
|
|
2642
|
+
isChildMode && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2643
|
+
TabsTrigger,
|
|
2644
|
+
{
|
|
2645
|
+
value: "info",
|
|
2646
|
+
className: "hover:bg-background/50 data-[state=active]:bg-background/50 flex items-center gap-2 rounded-none border-none bg-transparent",
|
|
2647
|
+
children: [
|
|
2648
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MonitorSmartphone, { className: "h-4 w-4" }),
|
|
2649
|
+
"Platform"
|
|
2650
|
+
]
|
|
2651
|
+
}
|
|
2652
|
+
),
|
|
2653
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2654
|
+
TabsTrigger,
|
|
2655
|
+
{
|
|
2656
|
+
value: "settings",
|
|
2657
|
+
className: "hover:bg-background/50 data-[state=active]:bg-background/50 flex items-center gap-2 rounded-none border-none bg-transparent",
|
|
2658
|
+
children: [
|
|
2659
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "h-4 w-4" }),
|
|
2660
|
+
"Settings"
|
|
2661
|
+
]
|
|
2662
|
+
}
|
|
2663
|
+
)
|
|
2664
|
+
] }),
|
|
2665
|
+
!isChildMode && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2666
|
+
TabsContent,
|
|
2667
|
+
{
|
|
2668
|
+
value: "room-code",
|
|
2669
|
+
className: "mt-0 min-h-0 flex-1 overflow-y-auto",
|
|
2670
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-[auto_1fr]", children: [
|
|
2671
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-start gap-4", children: [
|
|
2672
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
2673
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-3xl font-bold tracking-wider", children: roomId }),
|
|
2674
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2675
|
+
Badge,
|
|
2676
|
+
{
|
|
2677
|
+
variant: connectionVariant,
|
|
2678
|
+
className: "w-fit",
|
|
2679
|
+
children: statusCopy[connectionStatus]
|
|
2680
|
+
}
|
|
2681
|
+
)
|
|
2682
|
+
] }),
|
|
2683
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-border bg-card w-48 shrink-0 overflow-hidden rounded-lg border-2 shadow-md", children: qrUrl ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2684
|
+
"img",
|
|
2685
|
+
{
|
|
2686
|
+
src: qrUrl,
|
|
2687
|
+
alt: `Join room ${roomId}`,
|
|
2688
|
+
className: "w-full rounded bg-white"
|
|
2689
|
+
}
|
|
2690
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground flex h-48 items-center justify-center text-sm", children: qrError ? `QR failed: ${qrError}` : "Generating QR code\u2026" }) })
|
|
2691
|
+
] }),
|
|
2692
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
2693
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2694
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardDescription, { className: "text-xs tracking-[0.18em] uppercase", children: "Join URL" }),
|
|
2695
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
2696
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2697
|
+
"input",
|
|
2698
|
+
{
|
|
2699
|
+
type: "text",
|
|
2700
|
+
readOnly: true,
|
|
2701
|
+
value: joinUrl,
|
|
2702
|
+
className: "bg-background border-input text-foreground focus:ring-ring flex h-10 w-full rounded-md border px-3 py-2 font-mono text-xs focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
|
|
2703
|
+
}
|
|
2704
|
+
),
|
|
2705
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2706
|
+
Button,
|
|
2707
|
+
{
|
|
2708
|
+
type: "button",
|
|
2709
|
+
variant: "outline",
|
|
2710
|
+
size: "icon",
|
|
2711
|
+
onClick: handleCopyUrl,
|
|
2712
|
+
className: "h-10 shrink-0",
|
|
2713
|
+
"aria-label": "Copy join URL",
|
|
2714
|
+
children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-4 w-4" })
|
|
2715
|
+
}
|
|
2716
|
+
),
|
|
2717
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2718
|
+
Button,
|
|
2719
|
+
{
|
|
2720
|
+
type: "button",
|
|
2721
|
+
variant: "outline",
|
|
2722
|
+
size: "icon",
|
|
2723
|
+
onClick: handleOpenInNewTab,
|
|
2724
|
+
className: "h-10 shrink-0",
|
|
2725
|
+
"aria-label": "Open join URL in new tab",
|
|
2726
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "h-4 w-4" })
|
|
2727
|
+
}
|
|
2728
|
+
)
|
|
2729
|
+
] })
|
|
2730
|
+
] }),
|
|
2731
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: players.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-white", children: "Waiting for controllers to join\u2026" }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2732
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-foreground text-sm font-medium", children: [
|
|
2733
|
+
"Connected Players (",
|
|
2734
|
+
players.length,
|
|
2735
|
+
")"
|
|
2736
|
+
] }),
|
|
2737
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3", children: players.map((player) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2738
|
+
"li",
|
|
2739
|
+
{
|
|
2740
|
+
className: "flex min-w-0 flex-col items-start gap-2",
|
|
2741
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full min-w-0 items-center gap-2", children: [
|
|
2742
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2743
|
+
PlayerAvatar,
|
|
2744
|
+
{
|
|
2745
|
+
player,
|
|
2746
|
+
size: "md"
|
|
2747
|
+
}
|
|
2748
|
+
),
|
|
2749
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 overflow-hidden", children: [
|
|
2750
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-card-foreground truncate text-sm font-medium", children: player.label }),
|
|
2751
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2752
|
+
"div",
|
|
2753
|
+
{
|
|
2754
|
+
onClick: () => handleCopyPlayerId(player.id),
|
|
2755
|
+
className: "text-muted-foreground m-0 inline min-w-0 cursor-pointer truncate border-0 font-mono text-xs transition-colors hover:text-white",
|
|
2756
|
+
title: "Click to copy player ID",
|
|
2757
|
+
children: copiedPlayerId === player.id ? "Copied!" : player.id.slice(0, 8)
|
|
2758
|
+
}
|
|
2759
|
+
)
|
|
2760
|
+
] })
|
|
2761
|
+
] })
|
|
2762
|
+
},
|
|
2763
|
+
player.id
|
|
2764
|
+
)) })
|
|
2765
|
+
] }) }),
|
|
2766
|
+
lastError && /* @__PURE__ */ jsxRuntime.jsx(Alert, { variant: "destructive", className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(AlertDescription, { children: lastError }) }),
|
|
2767
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-auto flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2768
|
+
Button,
|
|
2769
|
+
{
|
|
2770
|
+
type: "button",
|
|
2771
|
+
onClick: toggleGameState,
|
|
2772
|
+
size: "lg",
|
|
2773
|
+
children: [
|
|
2774
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "mr-2 h-5 w-5" }),
|
|
2775
|
+
"Play"
|
|
2776
|
+
]
|
|
2777
|
+
}
|
|
2778
|
+
) })
|
|
2779
|
+
] })
|
|
2780
|
+
] }) })
|
|
2781
|
+
}
|
|
2856
2782
|
),
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
]
|
|
2900
|
-
}
|
|
2901
|
-
),
|
|
2902
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2903
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs tracking-[0.24em] uppercase", children: "Room" }),
|
|
2904
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-foreground text-lg font-semibold", children: typeof window !== "undefined" ? roomId ?? "N/A" : "N/A" })
|
|
2905
|
-
] })
|
|
2906
|
-
] }),
|
|
2907
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pointer-events-auto flex items-center gap-3", children: [
|
|
2908
|
-
customActions,
|
|
2909
|
-
onRefresh && roomId && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2910
|
-
Button,
|
|
2911
|
-
{
|
|
2912
|
-
type: "button",
|
|
2913
|
-
variant: "outline",
|
|
2914
|
-
size: "icon",
|
|
2915
|
-
onClick: onRefresh,
|
|
2916
|
-
disabled: connectionStatus === "connecting" || connectionStatus === "reconnecting",
|
|
2917
|
-
"aria-label": "Reconnect",
|
|
2918
|
-
title: "Reconnect to room",
|
|
2919
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2920
|
-
lucideReact.RefreshCw,
|
|
2921
|
-
{
|
|
2922
|
-
className: cn(
|
|
2923
|
-
"h-5 w-5",
|
|
2924
|
-
(connectionStatus === "connecting" || connectionStatus === "reconnecting") && "animate-spin"
|
|
2925
|
-
)
|
|
2926
|
-
}
|
|
2927
|
-
)
|
|
2928
|
-
}
|
|
2929
|
-
),
|
|
2930
|
-
onReconnect && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2931
|
-
Button,
|
|
2932
|
-
{
|
|
2933
|
-
type: "button",
|
|
2934
|
-
variant: "outline",
|
|
2935
|
-
size: "icon",
|
|
2936
|
-
onClick: () => setIsScannerOpen(true),
|
|
2937
|
-
"aria-label": "Scan QR code to reconnect",
|
|
2938
|
-
title: "Scan QR code to reconnect",
|
|
2939
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.QrCode, { className: "h-5 w-5" })
|
|
2940
|
-
}
|
|
2941
|
-
),
|
|
2942
|
-
onTogglePlayPause && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2943
|
-
Button,
|
|
2944
|
-
{
|
|
2945
|
-
type: "button",
|
|
2946
|
-
variant: "outline",
|
|
2947
|
-
size: "icon",
|
|
2948
|
-
onClick: onTogglePlayPause,
|
|
2949
|
-
"aria-label": gameState === "playing" ? "Pause" : "Play",
|
|
2950
|
-
title: gameState === "playing" ? "Pause" : "Play",
|
|
2951
|
-
children: gameState === "playing" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, { className: "h-5 w-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "h-5 w-5" })
|
|
2952
|
-
}
|
|
2953
|
-
),
|
|
2954
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2955
|
-
Button,
|
|
2956
|
-
{
|
|
2957
|
-
type: "button",
|
|
2958
|
-
variant: "outline",
|
|
2959
|
-
size: "icon",
|
|
2960
|
-
onClick: () => toggleFullscreen(),
|
|
2961
|
-
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
|
|
2962
|
-
title: isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
|
|
2963
|
-
children: isFullscreen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize, { className: "h-5 w-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize, { className: "h-5 w-5" })
|
|
2964
|
-
}
|
|
2965
|
-
)
|
|
2966
|
-
] })
|
|
2967
|
-
] }),
|
|
2968
|
-
/* @__PURE__ */ jsxRuntime.jsx("main", { className: "relative flex min-h-0 flex-1 items-center justify-center overflow-hidden p-2 select-none sm:p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-card/95 absolute inset-0 z-10 flex flex-col items-center justify-center p-6 text-center shadow-lg backdrop-blur-sm", children: [
|
|
2969
|
-
!orientationOk && forceOrientation && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-background/95 absolute inset-0 z-10 flex flex-col items-center justify-center p-6 text-center shadow-lg backdrop-blur-sm", children: [
|
|
2970
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-card-foreground text-xl font-semibold", children: "Rotate your device" }),
|
|
2971
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground mt-2 text-sm", children: [
|
|
2972
|
-
"This game is best experienced in ",
|
|
2973
|
-
forceOrientation,
|
|
2974
|
-
" ",
|
|
2975
|
-
"orientation."
|
|
2976
|
-
] })
|
|
2977
|
-
] }),
|
|
2978
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2979
|
-
"div",
|
|
2980
|
-
{
|
|
2981
|
-
className: cn(
|
|
2982
|
-
"h-full w-full select-none",
|
|
2983
|
-
!orientationOk && "pointer-events-none opacity-30"
|
|
2783
|
+
isChildMode && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2784
|
+
TabsContent,
|
|
2785
|
+
{
|
|
2786
|
+
value: "info",
|
|
2787
|
+
className: "mt-0 min-h-0 flex-1 overflow-y-auto",
|
|
2788
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
2789
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
2790
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-2xl font-bold tracking-wider", children: "Connected to Platform" }),
|
|
2791
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardDescription, { children: "This game is running inside the Air Jam Platform." })
|
|
2792
|
+
] }),
|
|
2793
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2794
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-foreground text-sm font-medium", children: [
|
|
2795
|
+
"Connected Players (",
|
|
2796
|
+
players.length,
|
|
2797
|
+
")"
|
|
2798
|
+
] }),
|
|
2799
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3", children: players.map((player) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2800
|
+
"li",
|
|
2801
|
+
{
|
|
2802
|
+
className: "flex min-w-0 flex-col items-start gap-2",
|
|
2803
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full min-w-0 items-center gap-2", children: [
|
|
2804
|
+
/* @__PURE__ */ jsxRuntime.jsx(PlayerAvatar, { player, size: "md" }),
|
|
2805
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-card-foreground truncate text-sm font-medium", children: player.label }) })
|
|
2806
|
+
] })
|
|
2807
|
+
},
|
|
2808
|
+
player.id
|
|
2809
|
+
)) })
|
|
2810
|
+
] }),
|
|
2811
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2812
|
+
Button,
|
|
2813
|
+
{
|
|
2814
|
+
type: "button",
|
|
2815
|
+
onClick: toggleGameState,
|
|
2816
|
+
size: "lg",
|
|
2817
|
+
children: [
|
|
2818
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "mr-2 h-5 w-5" }),
|
|
2819
|
+
"Resume Game"
|
|
2820
|
+
]
|
|
2821
|
+
}
|
|
2822
|
+
) })
|
|
2823
|
+
] }) })
|
|
2824
|
+
}
|
|
2984
2825
|
),
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2826
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2827
|
+
TabsContent,
|
|
2828
|
+
{
|
|
2829
|
+
value: "settings",
|
|
2830
|
+
className: "mt-0 min-h-0 flex-1 overflow-y-auto",
|
|
2831
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CardContent, { className: "pt-6 pb-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntime.jsx(VolumeControls, {}) }),
|
|
2833
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 border-t pt-4", children: [
|
|
2834
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold", children: "Connection" }),
|
|
2835
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
2836
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2837
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Status" }),
|
|
2838
|
+
/* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: connectionVariant, children: statusCopy[connectionStatus] })
|
|
2839
|
+
] }),
|
|
2840
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2841
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Room ID" }),
|
|
2842
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: roomId })
|
|
2843
|
+
] }),
|
|
2844
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2845
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Players" }),
|
|
2846
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: players.length })
|
|
2847
|
+
] })
|
|
2848
|
+
] })
|
|
2849
|
+
] }),
|
|
2850
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 border-t pt-4", children: [
|
|
2851
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold", children: "Display" }),
|
|
2852
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
2853
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: "Game State" }),
|
|
2854
|
+
/* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", className: "capitalize", children: gameState })
|
|
2855
|
+
] }) })
|
|
2856
|
+
] })
|
|
2857
|
+
] }) })
|
|
2858
|
+
}
|
|
2859
|
+
)
|
|
2860
|
+
]
|
|
2999
2861
|
}
|
|
3000
|
-
)
|
|
3001
|
-
|
|
2862
|
+
) }) }) }),
|
|
2863
|
+
children
|
|
2864
|
+
] });
|
|
3002
2865
|
};
|
|
3003
2866
|
|
|
3004
2867
|
// src/events.ts
|
|
@@ -3865,8 +3728,6 @@ function createAirJamStore2(initializer) {
|
|
|
3865
3728
|
|
|
3866
3729
|
exports.AIRJAM_PROXY_PREFIX = AIRJAM_PROXY_PREFIX;
|
|
3867
3730
|
exports.AirJamContext = AirJamContext;
|
|
3868
|
-
exports.AirJamDebug = AirJamDebug;
|
|
3869
|
-
exports.AirJamOverlay = AirJamOverlay;
|
|
3870
3731
|
exports.AirJamProvider = AirJamProvider;
|
|
3871
3732
|
exports.AudioManager = AudioManager;
|
|
3872
3733
|
exports.AudioProvider = AudioProvider;
|
|
@@ -3878,10 +3739,10 @@ exports.ControllerEvents = ControllerEvents;
|
|
|
3878
3739
|
exports.ControllerShell = ControllerShell;
|
|
3879
3740
|
exports.DEFAULT_MAX_PLAYERS = DEFAULT_MAX_PLAYERS;
|
|
3880
3741
|
exports.DEFAULT_SERVER_PORT = DEFAULT_SERVER_PORT;
|
|
3881
|
-
exports.DebugStateDialog = DebugStateDialog;
|
|
3882
3742
|
exports.ErrorCode = ErrorCode;
|
|
3883
3743
|
exports.Events = Events;
|
|
3884
3744
|
exports.HostEvents = HostEvents;
|
|
3745
|
+
exports.HostShell = HostShell;
|
|
3885
3746
|
exports.INPUT_DEBOUNCE_MS = INPUT_DEBOUNCE_MS;
|
|
3886
3747
|
exports.PlayerAvatar = PlayerAvatar;
|
|
3887
3748
|
exports.SOCKET_CONFIG = SOCKET_CONFIG;
|