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