@air-jam/sdk 0.1.3 → 0.9.0
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/LICENSE +21 -0
- package/README.md +627 -57
- package/dist/agent-tooling-BSMGBix9.d.cts +123 -0
- package/dist/agent-tooling-BSMGBix9.d.ts +123 -0
- package/dist/agent-tooling.cjs +83 -0
- package/dist/agent-tooling.cjs.map +1 -0
- package/dist/agent-tooling.d.cts +2 -0
- package/dist/agent-tooling.d.ts +2 -0
- package/dist/agent-tooling.js +17 -0
- package/dist/agent-tooling.js.map +1 -0
- package/dist/arcade/bridge/controller.cjs +749 -0
- package/dist/arcade/bridge/controller.cjs.map +1 -0
- package/dist/arcade/bridge/controller.d.cts +85 -0
- package/dist/arcade/bridge/controller.d.ts +85 -0
- package/dist/arcade/bridge/controller.js +33 -0
- package/dist/arcade/bridge/controller.js.map +1 -0
- package/dist/arcade/bridge/host.cjs +421 -0
- package/dist/arcade/bridge/host.cjs.map +1 -0
- package/dist/arcade/bridge/host.d.cts +73 -0
- package/dist/arcade/bridge/host.d.ts +73 -0
- package/dist/arcade/bridge/host.js +25 -0
- package/dist/arcade/bridge/host.js.map +1 -0
- package/dist/arcade/bridge/iframe.cjs +453 -0
- package/dist/arcade/bridge/iframe.cjs.map +1 -0
- package/dist/arcade/bridge/iframe.d.cts +80 -0
- package/dist/arcade/bridge/iframe.d.ts +80 -0
- package/dist/arcade/bridge/iframe.js +28 -0
- package/dist/arcade/bridge/iframe.js.map +1 -0
- package/dist/arcade/bridge.cjs +1067 -0
- package/dist/arcade/bridge.cjs.map +1 -0
- package/dist/arcade/bridge.d.cts +11 -0
- package/dist/arcade/bridge.d.ts +11 -0
- package/dist/arcade/bridge.js +76 -0
- package/dist/arcade/bridge.js.map +1 -0
- package/dist/arcade/host.cjs +488 -0
- package/dist/arcade/host.cjs.map +1 -0
- package/dist/arcade/host.d.cts +19 -0
- package/dist/arcade/host.d.ts +19 -0
- package/dist/arcade/host.js +13 -0
- package/dist/arcade/host.js.map +1 -0
- package/dist/arcade/surface.cjs +113 -0
- package/dist/arcade/surface.cjs.map +1 -0
- package/dist/arcade/surface.d.cts +14 -0
- package/dist/arcade/surface.d.ts +14 -0
- package/dist/arcade/surface.js +27 -0
- package/dist/arcade/surface.js.map +1 -0
- package/dist/arcade/url.cjs +363 -0
- package/dist/arcade/url.cjs.map +1 -0
- package/dist/arcade/url.d.cts +68 -0
- package/dist/arcade/url.d.ts +68 -0
- package/dist/arcade/url.js +28 -0
- package/dist/arcade/url.js.map +1 -0
- package/dist/arcade-runtime-url-BW-MUAOY.d.cts +28 -0
- package/dist/arcade-runtime-url-l8qj01Pg.d.ts +28 -0
- package/dist/arcade-surface-identity-CQxDpn_w.d.cts +16 -0
- package/dist/arcade-surface-identity-CQxDpn_w.d.ts +16 -0
- package/dist/arcade.cjs +1565 -0
- package/dist/arcade.cjs.map +1 -0
- package/dist/arcade.d.cts +18 -0
- package/dist/arcade.d.ts +18 -0
- package/dist/arcade.js +122 -0
- package/dist/arcade.js.map +1 -0
- package/dist/capabilities.cjs +39 -0
- package/dist/capabilities.cjs.map +1 -0
- package/dist/capabilities.d.cts +31 -0
- package/dist/capabilities.d.ts +31 -0
- package/dist/capabilities.js +12 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chunk-2432OL7L.js +193 -0
- package/dist/chunk-2432OL7L.js.map +1 -0
- package/dist/chunk-2J65FXEP.js +41 -0
- package/dist/chunk-2J65FXEP.js.map +1 -0
- package/dist/chunk-32NYL7XI.js +539 -0
- package/dist/chunk-32NYL7XI.js.map +1 -0
- package/dist/chunk-3USU7GY2.js +54 -0
- package/dist/chunk-3USU7GY2.js.map +1 -0
- package/dist/chunk-BE6Z4SIT.js +65 -0
- package/dist/chunk-BE6Z4SIT.js.map +1 -0
- package/dist/chunk-CQUG24WX.js +249 -0
- package/dist/chunk-CQUG24WX.js.map +1 -0
- package/dist/chunk-D3X4MN4U.js +288 -0
- package/dist/chunk-D3X4MN4U.js.map +1 -0
- package/dist/chunk-EVZJA6RN.js +140 -0
- package/dist/chunk-EVZJA6RN.js.map +1 -0
- package/dist/chunk-HFWRZVZ3.js +1438 -0
- package/dist/chunk-HFWRZVZ3.js.map +1 -0
- package/dist/chunk-IKKDONQL.js +1 -0
- package/dist/chunk-IKKDONQL.js.map +1 -0
- package/dist/chunk-JTF47B56.js +1 -0
- package/dist/chunk-JTF47B56.js.map +1 -0
- package/dist/chunk-LIXPF4P6.js +22 -0
- package/dist/chunk-LIXPF4P6.js.map +1 -0
- package/dist/chunk-MKBASO6X.js +216 -0
- package/dist/chunk-MKBASO6X.js.map +1 -0
- package/dist/chunk-MPDMJIX5.js +1 -0
- package/dist/chunk-MPDMJIX5.js.map +1 -0
- package/dist/chunk-NCL6WJCL.js +91 -0
- package/dist/chunk-NCL6WJCL.js.map +1 -0
- package/dist/chunk-NU5W6VAV.js +126 -0
- package/dist/chunk-NU5W6VAV.js.map +1 -0
- package/dist/chunk-TGRTEWYV.js +195 -0
- package/dist/chunk-TGRTEWYV.js.map +1 -0
- package/dist/chunk-VDRNNGHX.js +184 -0
- package/dist/chunk-VDRNNGHX.js.map +1 -0
- package/dist/chunk-VN5LDWVN.js +32 -0
- package/dist/chunk-VN5LDWVN.js.map +1 -0
- package/dist/chunk-W2VK36RO.js +11 -0
- package/dist/chunk-W2VK36RO.js.map +1 -0
- package/dist/chunk-X24K52DG.js +12 -0
- package/dist/chunk-X24K52DG.js.map +1 -0
- package/dist/chunk-XLUWV45V.js +25 -0
- package/dist/chunk-XLUWV45V.js.map +1 -0
- package/dist/chunk-Y4RAPKKB.js +238 -0
- package/dist/chunk-Y4RAPKKB.js.map +1 -0
- package/dist/chunk-YXHH3MQT.js +230 -0
- package/dist/chunk-YXHH3MQT.js.map +1 -0
- package/dist/chunk-ZLPL2R3R.js +183 -0
- package/dist/chunk-ZLPL2R3R.js.map +1 -0
- package/dist/chunk-ZTQ5SP4H.js +9 -0
- package/dist/chunk-ZTQ5SP4H.js.map +1 -0
- package/dist/controller-Bod8YYr1.d.cts +172 -0
- package/dist/controller-DxVchfiA.d.ts +172 -0
- package/dist/dev-log-events-CVAM29hx.d.cts +123 -0
- package/dist/dev-log-events-CVAM29hx.d.ts +123 -0
- package/dist/handshake-CC_LrK5g.d.cts +31 -0
- package/dist/handshake-CC_LrK5g.d.ts +31 -0
- package/dist/host-8hmq_Sgc.d.cts +109 -0
- package/dist/host-Cw-N6e-5.d.ts +109 -0
- package/dist/index.cjs +8512 -3518
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +676 -1070
- package/dist/index.d.ts +676 -1070
- package/dist/index.js +4892 -3188
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs +114 -0
- package/dist/metadata.cjs.map +1 -0
- package/dist/metadata.d.cts +95 -0
- package/dist/metadata.d.ts +95 -0
- package/dist/metadata.js +83 -0
- package/dist/metadata.js.map +1 -0
- package/dist/notices-CnGaaS8B.d.ts +38 -0
- package/dist/notices-NyDM5Mtz.d.cts +38 -0
- package/dist/platform-machine.cjs +425 -0
- package/dist/platform-machine.cjs.map +1 -0
- package/dist/platform-machine.d.cts +1183 -0
- package/dist/platform-machine.d.ts +1183 -0
- package/dist/platform-machine.js +309 -0
- package/dist/platform-machine.js.map +1 -0
- package/dist/platform-settings-cuor3i11.d.cts +48 -0
- package/dist/platform-settings-cuor3i11.d.ts +48 -0
- package/dist/prefabs.cjs +36 -0
- package/dist/prefabs.cjs.map +1 -0
- package/dist/prefabs.d.cts +49 -0
- package/dist/prefabs.d.ts +49 -0
- package/dist/prefabs.js +8 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/preview.cjs +2609 -0
- package/dist/preview.cjs.map +1 -0
- package/dist/preview.d.cts +155 -0
- package/dist/preview.d.ts +155 -0
- package/dist/preview.js +1671 -0
- package/dist/preview.js.map +1 -0
- package/dist/protocol.cjs +621 -54
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +76 -240
- package/dist/protocol.d.ts +76 -240
- package/dist/protocol.js +100 -2
- package/dist/protocol.js.map +1 -1
- package/dist/realtime-client-Cu8yVJFw.d.cts +15 -0
- package/dist/realtime-client-Cu8yVJFw.d.ts +15 -0
- package/dist/release.cjs +143 -0
- package/dist/release.cjs.map +1 -0
- package/dist/release.d.cts +64 -0
- package/dist/release.d.ts +64 -0
- package/dist/release.js +43 -0
- package/dist/release.js.map +1 -0
- package/dist/standard-match-phase-BucA5dYo.d.ts +44 -0
- package/dist/standard-match-phase-U2ra8J-0.d.cts +44 -0
- package/dist/sync-B6QsNrXz.d.cts +125 -0
- package/dist/sync-B6QsNrXz.d.ts +125 -0
- package/dist/ui.cjs +2827 -0
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +320 -0
- package/dist/ui.d.ts +320 -0
- package/dist/ui.js +1718 -0
- package/dist/ui.js.map +1 -0
- package/dist/url-policy-C89zxgw9.d.cts +9 -0
- package/dist/url-policy-C89zxgw9.d.ts +9 -0
- package/package.json +154 -13
- package/src/agent/agent-action.ts +304 -0
- package/src/agent/agent-contract.ts +180 -0
- package/src/agent-tooling.ts +20 -0
- package/src/arcade/bridge/controller.ts +15 -0
- package/src/arcade/bridge/host.ts +12 -0
- package/src/arcade/bridge/iframe.ts +61 -0
- package/src/arcade/bridge.ts +3 -0
- package/src/arcade/host.ts +1 -0
- package/src/arcade/surface.ts +4 -0
- package/src/arcade/url.ts +60 -0
- package/src/arcade.ts +4 -0
- package/src/audio/audio-manager.ts +162 -171
- package/src/audio/hooks.tsx +218 -97
- package/src/audio/index.ts +1 -1
- package/src/audio/music.tsx +139 -0
- package/src/capabilities/manifest.ts +71 -0
- package/src/capabilities.ts +12 -0
- package/src/components/connection-status-pill.tsx +55 -0
- package/src/components/controller-player-name-field.tsx +119 -0
- package/src/components/controller-primary-action.tsx +58 -0
- package/src/components/host-mute-button.tsx +49 -0
- package/src/components/join-qr-overlay.tsx +133 -0
- package/src/components/join-url-action-buttons.tsx +95 -0
- package/src/components/join-url-controls.tsx +58 -0
- package/src/components/join-url-field.tsx +52 -0
- package/src/components/lifecycle-action-group.tsx +129 -0
- package/src/components/player-avatar-strip.tsx +65 -0
- package/src/components/player-avatar.tsx +42 -14
- package/src/components/room-qr-code.tsx +125 -0
- package/src/components/runtime-shell-header.tsx +37 -0
- package/src/components/shell-classes.ts +19 -0
- package/src/components/surface-orientation-layout.ts +60 -0
- package/src/components/surface-viewport-layout.ts +268 -0
- package/src/components/surface-viewport.tsx +314 -0
- package/src/components/ui/button.tsx +4 -6
- package/src/components/ui/slider.tsx +1 -1
- package/src/components/volume-controls.tsx +65 -6
- package/src/context/air-jam-context.tsx +209 -141
- package/src/context/index.ts +2 -2
- package/src/context/session-providers.tsx +77 -0
- package/src/context/session-scope.ts +64 -0
- package/src/context/socket-manager.ts +6 -25
- package/src/contracts/v2/bridge.ts +261 -0
- package/src/contracts/v2/handshake.ts +40 -0
- package/src/contracts/v2/index.ts +2 -0
- package/src/dev/browser-log-sink.ts +912 -0
- package/src/diagnostics.ts +128 -0
- package/src/events.ts +7 -34
- package/src/hooks/internal/use-controller-runtime-api.ts +875 -0
- package/src/hooks/internal/use-host-runtime-api.ts +1051 -0
- package/src/hooks/internal/use-runtime-control-contract.ts +15 -0
- package/src/hooks/internal/use-runtime-inspection-contract.ts +16 -0
- package/src/hooks/internal/use-runtime-observability-contract.ts +24 -0
- package/src/hooks/use-air-jam-controller.ts +155 -475
- package/src/hooks/use-air-jam-host.ts +156 -485
- package/src/hooks/use-connection-status.ts +8 -0
- package/src/hooks/use-controller-lifecycle-intents.ts +27 -0
- package/src/hooks/use-controller-lifecycle-permissions.ts +36 -0
- package/src/hooks/use-controller-shell-status.ts +40 -0
- package/src/hooks/use-controller-tick.ts +65 -0
- package/src/hooks/use-controller-toasts.ts +116 -0
- package/src/hooks/use-get-input.ts +8 -5
- package/src/hooks/use-host-arcade-restore.ts +30 -0
- package/src/hooks/use-host-join-controls.ts +152 -0
- package/src/hooks/use-host-tick.ts +171 -0
- package/src/hooks/use-input-writer.ts +83 -0
- package/src/hooks/use-lifecycle-action-group-model.ts +98 -0
- package/src/hooks/use-players.ts +12 -0
- package/src/hooks/use-room.ts +22 -0
- package/src/hooks/use-send-signal.ts +6 -2
- package/src/index.ts +205 -31
- package/src/internal/input-manager.ts +195 -215
- package/src/lifecycle/index.ts +9 -0
- package/src/lifecycle/standard-match-phase.ts +32 -0
- package/src/metadata/manifest.ts +152 -0
- package/src/metadata.ts +12 -0
- package/src/platform-machine.ts +475 -0
- package/src/prefabs/types.ts +82 -0
- package/src/prefabs.ts +12 -0
- package/src/preview/host-workspace.tsx +59 -0
- package/src/preview/identity.ts +66 -0
- package/src/preview/layout.ts +223 -0
- package/src/preview/manager.ts +577 -0
- package/src/preview/messages.ts +26 -0
- package/src/preview/ownership.ts +81 -0
- package/src/preview/url.ts +117 -0
- package/src/preview/window.tsx +490 -0
- package/src/preview/workspace.tsx +678 -0
- package/src/preview.ts +42 -0
- package/src/protocol/arcade-platform-actions.ts +29 -0
- package/src/protocol/controller.ts +187 -0
- package/src/protocol/core.ts +23 -0
- package/src/protocol/dev-log-events.ts +222 -0
- package/src/protocol/errors.ts +21 -0
- package/src/protocol/host-grant.ts +185 -0
- package/src/protocol/host.ts +138 -0
- package/src/protocol/notices.ts +43 -0
- package/src/protocol/signals.ts +38 -0
- package/src/protocol/socket-events.ts +154 -0
- package/src/protocol/sync.ts +121 -0
- package/src/protocol/url-policy.ts +63 -0
- package/src/protocol.ts +12 -386
- package/src/qrcode.d.ts +16 -0
- package/src/release.ts +99 -0
- package/src/runtime/air-jam-config.ts +287 -0
- package/src/runtime/air-jam-error-boundary.tsx +672 -0
- package/src/runtime/arcade-bridge-request-surface.ts +15 -0
- package/src/runtime/arcade-runtime-url.ts +95 -0
- package/src/runtime/arcade-surface-identity.ts +16 -0
- package/src/runtime/contracts/control.ts +68 -0
- package/src/runtime/contracts/inspection.ts +165 -0
- package/src/runtime/contracts/observability.ts +94 -0
- package/src/runtime/controller-bridge.ts +451 -0
- package/src/runtime/controller-identity.ts +132 -0
- package/src/runtime/controller-presentation.ts +24 -0
- package/src/runtime/controller-realtime-client.ts +591 -0
- package/src/runtime/create-air-jam-app.tsx +260 -0
- package/src/runtime/dev-runtime-events.ts +36 -0
- package/src/runtime/embedded-runtime-adapters.ts +68 -0
- package/src/runtime/host-bridge.ts +388 -0
- package/src/runtime/host-realtime-client.ts +550 -0
- package/src/runtime/iframe-bridge.ts +135 -0
- package/src/runtime/realtime-client.ts +20 -0
- package/src/runtime/router-basename.ts +25 -0
- package/src/runtime/runtime-owner-contexts.tsx +4 -0
- package/src/runtime/runtime-session-params.ts +169 -0
- package/src/runtime/sdk-version.ts +6 -0
- package/src/runtime/session-runtimes.tsx +188 -0
- package/src/runtime/validate-arcade-bridge-attach.ts +14 -0
- package/src/runtime-control.ts +10 -0
- package/src/runtime-inspection.ts +14 -0
- package/src/runtime-observability.ts +9 -0
- package/src/settings/platform-settings-bridge.ts +336 -0
- package/src/settings/platform-settings-runtime.tsx +387 -0
- package/src/settings/platform-settings.ts +288 -0
- package/src/state/connection-store.ts +80 -12
- package/src/store/air-jam-store-domain-constants.ts +4 -0
- package/src/store/create-air-jam-store.ts +1094 -227
- package/src/styles.css +4 -38
- package/src/ui.ts +29 -0
- package/src/utils/is-rpc-serializable.ts +56 -0
- package/src/utils/player-avatar-url.ts +48 -0
- package/src/utils/url-builder.ts +7 -0
- package/dist/.tsbuildinfo +0 -1
- package/dist/chunk-B5DURUWT.js +0 -80
- package/dist/chunk-B5DURUWT.js.map +0 -1
- package/src/AirJamClient.ts +0 -224
- package/src/audio/volume-store.ts +0 -124
- package/src/components/controller-shell.tsx +0 -346
- package/src/components/host-shell.tsx +0 -521
- package/src/components/qr-scanner-dialog.tsx +0 -373
- package/src/components/ui/alert.tsx +0 -66
- package/src/components/ui/avatar.tsx +0 -46
- package/src/components/ui/badge.tsx +0 -47
- package/src/components/ui/card.tsx +0 -92
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/tabs.tsx +0 -64
- package/src/hooks/use-air-jam-shell.ts +0 -379
- package/src/hooks/use-fullscreen.ts +0 -108
package/src/audio/hooks.tsx
CHANGED
|
@@ -1,140 +1,261 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useState,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
} from "react";
|
|
3
10
|
import { useStore } from "zustand";
|
|
4
11
|
import { useAirJamContext } from "../context/air-jam-context";
|
|
5
|
-
import {
|
|
12
|
+
import type { PlaySoundPayload } from "../protocol";
|
|
13
|
+
import { getControllerRealtimeClient } from "../runtime/controller-realtime-client";
|
|
14
|
+
import { getHostRealtimeClient } from "../runtime/host-realtime-client";
|
|
15
|
+
import {
|
|
16
|
+
usePlatformSettingsRuntimeStatus,
|
|
17
|
+
useResolvedPlatformSettingsSnapshot,
|
|
18
|
+
} from "../settings/platform-settings-runtime";
|
|
19
|
+
import {
|
|
20
|
+
AudioManager,
|
|
21
|
+
type AudioHandle,
|
|
22
|
+
type SoundManifest,
|
|
23
|
+
} from "./audio-manager";
|
|
6
24
|
|
|
7
|
-
// Module-level singleton manager cache
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
const managerCache = new WeakMap<SoundManifest, AudioManager<any>>();
|
|
10
25
|
let globalInitialized = false;
|
|
26
|
+
const audioManagerContext = createContext<AudioHandle<string> | null>(null);
|
|
27
|
+
const audioRuntimeStatusContext = createContext<AudioRuntimeStatus | null>(
|
|
28
|
+
null,
|
|
29
|
+
);
|
|
30
|
+
const audioRuntimeControlsContext = createContext<AudioRuntimeControls | null>(
|
|
31
|
+
null,
|
|
32
|
+
);
|
|
11
33
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
34
|
+
export type AudioRuntimeStatus = "idle" | "blocked" | "ready";
|
|
35
|
+
|
|
36
|
+
export interface AudioRuntimeControls {
|
|
37
|
+
retry: () => Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AudioRuntimeProps<M extends SoundManifest = SoundManifest> {
|
|
41
|
+
manifest: M;
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function AudioRuntime<M extends SoundManifest>({
|
|
46
|
+
manifest,
|
|
47
|
+
children,
|
|
48
|
+
}: AudioRuntimeProps<M>) {
|
|
49
|
+
const { manager, status, controls } = useOwnedAudio(manifest);
|
|
50
|
+
|
|
51
|
+
useRemoteSound(manifest, manager);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<audioRuntimeStatusContext.Provider value={status}>
|
|
55
|
+
<audioRuntimeControlsContext.Provider value={controls}>
|
|
56
|
+
<audioManagerContext.Provider value={manager as AudioHandle<string>}>
|
|
57
|
+
{children}
|
|
58
|
+
</audioManagerContext.Provider>
|
|
59
|
+
</audioRuntimeControlsContext.Provider>
|
|
60
|
+
</audioRuntimeStatusContext.Provider>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function useAudio<T extends string = string>(): AudioHandle<T> {
|
|
65
|
+
const manager = useContext(audioManagerContext);
|
|
66
|
+
|
|
67
|
+
if (!manager) {
|
|
68
|
+
throw new Error("useAudio must be used within an AudioRuntime");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return manager as AudioHandle<T>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function useAudioRuntimeStatus(): AudioRuntimeStatus {
|
|
75
|
+
const status = useContext(audioRuntimeStatusContext);
|
|
76
|
+
|
|
77
|
+
if (!status) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"useAudioRuntimeStatus must be used within an AudioRuntime",
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return status;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function useAudioRuntimeControls(): AudioRuntimeControls {
|
|
87
|
+
const controls = useContext(audioRuntimeControlsContext);
|
|
88
|
+
|
|
89
|
+
if (!controls) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"useAudioRuntimeControls must be used within an AudioRuntime",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return controls;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function useOwnedAudio<M extends SoundManifest>(
|
|
19
99
|
manifest: M,
|
|
20
|
-
):
|
|
100
|
+
): {
|
|
101
|
+
manager: AudioManager<keyof M & string>;
|
|
102
|
+
status: AudioRuntimeStatus;
|
|
103
|
+
controls: AudioRuntimeControls;
|
|
104
|
+
} {
|
|
21
105
|
const { store, getSocket } = useAirJamContext();
|
|
22
106
|
const roomId = useStore(store, (state) => state.roomId);
|
|
23
107
|
const role = useStore(store, (state) => state.role);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
108
|
+
const platformSettings = useResolvedPlatformSettingsSnapshot();
|
|
109
|
+
const platformSettingsStatus = usePlatformSettingsRuntimeStatus();
|
|
110
|
+
const platformSettingsReady = platformSettingsStatus === "ready";
|
|
27
111
|
type SoundId = keyof M & string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
112
|
+
const manager = useMemo(
|
|
113
|
+
() => new AudioManager<SoundId>(manifest),
|
|
114
|
+
[manifest],
|
|
115
|
+
);
|
|
116
|
+
const [status, setStatus] = useState<AudioRuntimeStatus>(() =>
|
|
117
|
+
globalInitialized && platformSettingsReady ? "ready" : "idle",
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const retry = useCallback(async () => {
|
|
121
|
+
if (!platformSettingsReady) {
|
|
122
|
+
setStatus("idle");
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const ready = await manager.init();
|
|
127
|
+
if (ready) {
|
|
128
|
+
globalInitialized = true;
|
|
129
|
+
setStatus("ready");
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
setStatus((current) => (current === "ready" ? current : "blocked"));
|
|
134
|
+
return false;
|
|
135
|
+
}, [manager, platformSettingsReady]);
|
|
136
|
+
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (!platformSettingsReady) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
manager.applyPlatformAudioSettings(platformSettings.audio);
|
|
143
|
+
}, [manager, platformSettings.audio, platformSettingsReady]);
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (platformSettingsReady) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
setStatus("idle");
|
|
151
|
+
}, [platformSettingsReady]);
|
|
33
152
|
|
|
34
|
-
// Inject socket into manager when connection is available
|
|
35
153
|
useEffect(() => {
|
|
36
154
|
if (role && roomId) {
|
|
37
|
-
const
|
|
38
|
-
|
|
155
|
+
const directSocket = getSocket(role);
|
|
156
|
+
if (!directSocket) {
|
|
157
|
+
manager.setSocket(null, roomId, role);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const realtimeClient =
|
|
162
|
+
role === "controller"
|
|
163
|
+
? getControllerRealtimeClient(() => directSocket)
|
|
164
|
+
: getHostRealtimeClient(() => directSocket);
|
|
165
|
+
manager.setSocket(realtimeClient, roomId, role);
|
|
39
166
|
}
|
|
40
167
|
}, [manager, role, roomId, getSocket]);
|
|
41
168
|
|
|
42
|
-
// Ensure audio context is resumed on first interaction (only once globally)
|
|
43
169
|
useEffect(() => {
|
|
44
|
-
|
|
170
|
+
return () => {
|
|
171
|
+
manager.destroy();
|
|
172
|
+
};
|
|
173
|
+
}, [manager]);
|
|
174
|
+
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
void retry();
|
|
177
|
+
}, [retry]);
|
|
178
|
+
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (status === "ready") {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
45
183
|
|
|
46
184
|
const handleInteraction = () => {
|
|
47
|
-
|
|
48
|
-
globalInitialized = true;
|
|
49
|
-
initRef.current = true;
|
|
50
|
-
window.removeEventListener("click", handleInteraction);
|
|
51
|
-
window.removeEventListener("touchstart", handleInteraction);
|
|
52
|
-
window.removeEventListener("keydown", handleInteraction);
|
|
185
|
+
void retry();
|
|
53
186
|
};
|
|
54
187
|
|
|
55
188
|
window.addEventListener("click", handleInteraction);
|
|
56
189
|
window.addEventListener("touchstart", handleInteraction);
|
|
57
190
|
window.addEventListener("keydown", handleInteraction);
|
|
191
|
+
window.addEventListener("pointerdown", handleInteraction);
|
|
192
|
+
window.addEventListener("mousedown", handleInteraction);
|
|
58
193
|
|
|
59
194
|
return () => {
|
|
60
195
|
window.removeEventListener("click", handleInteraction);
|
|
61
196
|
window.removeEventListener("touchstart", handleInteraction);
|
|
62
197
|
window.removeEventListener("keydown", handleInteraction);
|
|
198
|
+
window.removeEventListener("pointerdown", handleInteraction);
|
|
199
|
+
window.removeEventListener("mousedown", handleInteraction);
|
|
63
200
|
};
|
|
64
|
-
}, [
|
|
201
|
+
}, [retry, status]);
|
|
65
202
|
|
|
66
|
-
return
|
|
203
|
+
return {
|
|
204
|
+
manager,
|
|
205
|
+
status,
|
|
206
|
+
controls: {
|
|
207
|
+
retry,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
67
210
|
}
|
|
68
211
|
|
|
69
|
-
|
|
70
|
-
|
|
212
|
+
const isManifestSoundId = <M extends SoundManifest>(
|
|
213
|
+
manifest: M,
|
|
214
|
+
soundId: unknown,
|
|
215
|
+
): soundId is keyof M & string =>
|
|
216
|
+
typeof soundId === "string" &&
|
|
217
|
+
Object.prototype.hasOwnProperty.call(manifest, soundId);
|
|
71
218
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
-
manager: AudioManager<any>;
|
|
79
|
-
}) => {
|
|
80
|
-
const { store, getSocket } = useAirJamContext();
|
|
81
|
-
const roomId = useStore(store, (state) => state.roomId);
|
|
219
|
+
function useRemoteSound<M extends SoundManifest>(
|
|
220
|
+
manifest: M,
|
|
221
|
+
audio: Pick<AudioHandle<keyof M & string>, "play">,
|
|
222
|
+
): void {
|
|
223
|
+
const { getSocket, store } = useAirJamContext();
|
|
82
224
|
const role = useStore(store, (state) => state.role);
|
|
225
|
+
const connectionStatus = useStore(store, (state) => state.connectionStatus);
|
|
226
|
+
const socket = useMemo(() => {
|
|
227
|
+
if (role !== "controller") {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
83
230
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const socket = getSocket(role);
|
|
88
|
-
manager.setSocket(socket, roomId);
|
|
231
|
+
const directSocket = getSocket("controller");
|
|
232
|
+
if (!directSocket) {
|
|
233
|
+
return null;
|
|
89
234
|
}
|
|
90
|
-
}, [manager, role, roomId, getSocket]);
|
|
91
235
|
|
|
92
|
-
|
|
236
|
+
return getControllerRealtimeClient(() => directSocket);
|
|
237
|
+
}, [getSocket, role]);
|
|
238
|
+
const enabled = role === "controller" && connectionStatus === "connected";
|
|
239
|
+
|
|
93
240
|
useEffect(() => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
window.removeEventListener("touchstart", handleInteraction);
|
|
98
|
-
window.removeEventListener("keydown", handleInteraction);
|
|
99
|
-
};
|
|
241
|
+
if (!socket || !enabled) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
100
244
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
245
|
+
const handlePlaySound = (payload: PlaySoundPayload): void => {
|
|
246
|
+
if (!isManifestSoundId(manifest, payload.id)) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
104
249
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
250
|
+
audio.play(payload.id, {
|
|
251
|
+
volume: payload.volume,
|
|
252
|
+
loop: payload.loop,
|
|
253
|
+
});
|
|
109
254
|
};
|
|
110
|
-
}, [manager]);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<LegacyAudioContext.Provider value={manager}>
|
|
114
|
-
{children}
|
|
115
|
-
</LegacyAudioContext.Provider>
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
255
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Hook to create a stable AudioManager instance
|
|
129
|
-
*/
|
|
130
|
-
export const useAudioManager = <T extends string = string>(
|
|
131
|
-
manifest: SoundManifest,
|
|
132
|
-
) => {
|
|
133
|
-
const managerRef = useRef<AudioManager<T> | null>(null);
|
|
134
|
-
|
|
135
|
-
if (!managerRef.current) {
|
|
136
|
-
managerRef.current = new AudioManager<T>(manifest);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return managerRef.current;
|
|
140
|
-
};
|
|
256
|
+
socket.on("server:playSound", handlePlaySound);
|
|
257
|
+
return () => {
|
|
258
|
+
socket.off("server:playSound", handlePlaySound);
|
|
259
|
+
};
|
|
260
|
+
}, [audio, enabled, manifest, socket]);
|
|
261
|
+
}
|
package/src/audio/index.ts
CHANGED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { getEffectiveAudioVolume } from "../settings/platform-settings";
|
|
3
|
+
import {
|
|
4
|
+
usePlatformSettingsRuntimeStatus,
|
|
5
|
+
useResolvedPlatformSettingsSnapshot,
|
|
6
|
+
} from "../settings/platform-settings-runtime";
|
|
7
|
+
import { type SoundCategory } from "./audio-manager";
|
|
8
|
+
import { useAudio, useAudioRuntimeStatus } from "./hooks";
|
|
9
|
+
|
|
10
|
+
export type AudioVolumeCategory = SoundCategory | "master";
|
|
11
|
+
|
|
12
|
+
export interface MusicPlaylistProps<TTrackId extends string = string> {
|
|
13
|
+
tracks: readonly TTrackId[];
|
|
14
|
+
playing: boolean;
|
|
15
|
+
order?: "sequence" | "shuffle";
|
|
16
|
+
fadeMs?: number;
|
|
17
|
+
startIndex?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function useAudioCategoryVolume(category: AudioVolumeCategory): number {
|
|
21
|
+
const settingsStatus = usePlatformSettingsRuntimeStatus();
|
|
22
|
+
const settings = useResolvedPlatformSettingsSnapshot();
|
|
23
|
+
|
|
24
|
+
if (settingsStatus !== "ready") {
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (category === "master") {
|
|
29
|
+
return settings.audio.masterVolume;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return getEffectiveAudioVolume(settings.audio, category);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function useMusicVolume(): number {
|
|
36
|
+
return useAudioCategoryVolume("music");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function MusicPlaylist<TTrackId extends string = string>({
|
|
40
|
+
tracks,
|
|
41
|
+
playing,
|
|
42
|
+
order = "sequence",
|
|
43
|
+
fadeMs = 1000,
|
|
44
|
+
startIndex = 0,
|
|
45
|
+
}: MusicPlaylistProps<TTrackId>) {
|
|
46
|
+
const audio = useAudio<TTrackId>();
|
|
47
|
+
const status = useAudioRuntimeStatus();
|
|
48
|
+
const activeRef = useRef<{ trackId: TTrackId; soundId: number } | null>(null);
|
|
49
|
+
const generationRef = useRef(0);
|
|
50
|
+
const tracksRef = useRef(tracks);
|
|
51
|
+
const tracksKey = useMemo(() => tracks.join("\0"), [tracks]);
|
|
52
|
+
tracksRef.current = tracks;
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const generation = generationRef.current + 1;
|
|
56
|
+
generationRef.current = generation;
|
|
57
|
+
let disposed = false;
|
|
58
|
+
|
|
59
|
+
const stopActive = () => {
|
|
60
|
+
const active = activeRef.current;
|
|
61
|
+
if (!active) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
activeRef.current = null;
|
|
66
|
+
audio.fadeOutAndStop(active.trackId, active.soundId, fadeMs);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getNextIndex = (currentIndex: number): number => {
|
|
70
|
+
const currentTracks = tracksRef.current;
|
|
71
|
+
if (currentTracks.length <= 1) {
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (order === "shuffle") {
|
|
76
|
+
const randomOffset = Math.floor(
|
|
77
|
+
Math.random() * (currentTracks.length - 1),
|
|
78
|
+
);
|
|
79
|
+
return (currentIndex + 1 + randomOffset) % currentTracks.length;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (currentIndex + 1) % currentTracks.length;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const startTrack = (trackIndex: number) => {
|
|
86
|
+
const currentTracks = tracksRef.current;
|
|
87
|
+
if (
|
|
88
|
+
disposed ||
|
|
89
|
+
generationRef.current !== generation ||
|
|
90
|
+
!playing ||
|
|
91
|
+
status !== "ready" ||
|
|
92
|
+
currentTracks.length === 0
|
|
93
|
+
) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const normalizedIndex =
|
|
98
|
+
((trackIndex % currentTracks.length) + currentTracks.length) %
|
|
99
|
+
currentTracks.length;
|
|
100
|
+
const trackId = currentTracks[normalizedIndex];
|
|
101
|
+
const soundId = audio.play(trackId, {
|
|
102
|
+
fadeInMs: fadeMs,
|
|
103
|
+
loop: false,
|
|
104
|
+
onEnd: (endedSoundId) => {
|
|
105
|
+
const active = activeRef.current;
|
|
106
|
+
if (
|
|
107
|
+
disposed ||
|
|
108
|
+
generationRef.current !== generation ||
|
|
109
|
+
!active ||
|
|
110
|
+
active.trackId !== trackId ||
|
|
111
|
+
active.soundId !== endedSoundId
|
|
112
|
+
) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
activeRef.current = null;
|
|
117
|
+
startTrack(getNextIndex(normalizedIndex));
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (soundId !== null) {
|
|
122
|
+
activeRef.current = { trackId, soundId };
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
stopActive();
|
|
127
|
+
|
|
128
|
+
if (playing && status === "ready" && tracksRef.current.length > 0) {
|
|
129
|
+
startTrack(startIndex);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return () => {
|
|
133
|
+
disposed = true;
|
|
134
|
+
stopActive();
|
|
135
|
+
};
|
|
136
|
+
}, [audio, fadeMs, order, playing, startIndex, status, tracksKey]);
|
|
137
|
+
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type AirJamGameActionCapabilityKind =
|
|
2
|
+
| "button"
|
|
3
|
+
| "axis"
|
|
4
|
+
| "trigger"
|
|
5
|
+
| "command"
|
|
6
|
+
| "composite";
|
|
7
|
+
|
|
8
|
+
export type AirJamGameStateCapabilityKind =
|
|
9
|
+
| "phase"
|
|
10
|
+
| "boolean"
|
|
11
|
+
| "number"
|
|
12
|
+
| "enum"
|
|
13
|
+
| "text"
|
|
14
|
+
| "collection";
|
|
15
|
+
|
|
16
|
+
export type AirJamGameEvaluationCapabilityKind =
|
|
17
|
+
| "success"
|
|
18
|
+
| "failure"
|
|
19
|
+
| "progress"
|
|
20
|
+
| "score"
|
|
21
|
+
| "quality";
|
|
22
|
+
|
|
23
|
+
export type AirJamGameCapabilityAudience = "host" | "controller" | "shared";
|
|
24
|
+
|
|
25
|
+
interface AirJamGameCapabilityDescriptorBase {
|
|
26
|
+
key: string;
|
|
27
|
+
label: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
audience?: AirJamGameCapabilityAudience;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface AirJamGameActionCapability extends AirJamGameCapabilityDescriptorBase {
|
|
33
|
+
kind: AirJamGameActionCapabilityKind;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AirJamGameStateCapability extends AirJamGameCapabilityDescriptorBase {
|
|
37
|
+
kind: AirJamGameStateCapabilityKind;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AirJamGameEvaluationCapability extends AirJamGameCapabilityDescriptorBase {
|
|
41
|
+
kind: AirJamGameEvaluationCapabilityKind;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AirJamGameCapabilityManifest {
|
|
45
|
+
version: 1;
|
|
46
|
+
actions?: readonly AirJamGameActionCapability[];
|
|
47
|
+
state?: readonly AirJamGameStateCapability[];
|
|
48
|
+
evaluation?: readonly AirJamGameEvaluationCapability[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type DefineAirJamGameCapabilitiesInput = Omit<
|
|
52
|
+
AirJamGameCapabilityManifest,
|
|
53
|
+
"version"
|
|
54
|
+
> & {
|
|
55
|
+
version?: 1;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const cloneSection = <T>(
|
|
59
|
+
entries: readonly T[] | undefined,
|
|
60
|
+
): readonly T[] | undefined =>
|
|
61
|
+
entries ? Object.freeze([...entries]) : undefined;
|
|
62
|
+
|
|
63
|
+
export const defineAirJamGameCapabilities = (
|
|
64
|
+
input: DefineAirJamGameCapabilitiesInput,
|
|
65
|
+
): AirJamGameCapabilityManifest =>
|
|
66
|
+
Object.freeze({
|
|
67
|
+
version: 1,
|
|
68
|
+
actions: cloneSection(input.actions),
|
|
69
|
+
state: cloneSection(input.state),
|
|
70
|
+
evaluation: cloneSection(input.evaluation),
|
|
71
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
defineAirJamGameCapabilities,
|
|
3
|
+
type AirJamGameActionCapability,
|
|
4
|
+
type AirJamGameActionCapabilityKind,
|
|
5
|
+
type AirJamGameCapabilityAudience,
|
|
6
|
+
type AirJamGameCapabilityManifest,
|
|
7
|
+
type AirJamGameEvaluationCapability,
|
|
8
|
+
type AirJamGameEvaluationCapabilityKind,
|
|
9
|
+
type AirJamGameStateCapability,
|
|
10
|
+
type AirJamGameStateCapabilityKind,
|
|
11
|
+
type DefineAirJamGameCapabilitiesInput,
|
|
12
|
+
} from "./capabilities/manifest";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ConnectionStatus } from "../protocol";
|
|
2
|
+
import { cn } from "../utils/cn";
|
|
3
|
+
|
|
4
|
+
const statusLabelByConnection: Record<ConnectionStatus, string> = {
|
|
5
|
+
connected: "Live",
|
|
6
|
+
connecting: "Syncing",
|
|
7
|
+
reconnecting: "Syncing",
|
|
8
|
+
disconnected: "Offline",
|
|
9
|
+
idle: "Idle",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const statusToneByConnection: Record<ConnectionStatus, string> = {
|
|
13
|
+
connected: "border-emerald-400/18 bg-emerald-400/8 text-emerald-50",
|
|
14
|
+
connecting: "border-amber-400/18 bg-amber-400/8 text-amber-50",
|
|
15
|
+
reconnecting: "border-amber-400/18 bg-amber-400/8 text-amber-50",
|
|
16
|
+
disconnected: "border-rose-400/18 bg-rose-400/8 text-rose-50",
|
|
17
|
+
idle: "border-white/10 bg-white/[0.05] text-white/78",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const statusDotToneByConnection: Record<ConnectionStatus, string> = {
|
|
21
|
+
connected: "bg-emerald-300",
|
|
22
|
+
connecting: "bg-amber-300",
|
|
23
|
+
reconnecting: "bg-amber-300",
|
|
24
|
+
disconnected: "bg-rose-300",
|
|
25
|
+
idle: "bg-white/45",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export interface ConnectionStatusPillProps {
|
|
29
|
+
status: ConnectionStatus;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const ConnectionStatusPill = ({
|
|
34
|
+
status,
|
|
35
|
+
className,
|
|
36
|
+
}: ConnectionStatusPillProps) => {
|
|
37
|
+
return (
|
|
38
|
+
<span
|
|
39
|
+
className={cn(
|
|
40
|
+
"inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2.5 py-1 text-[0.625rem] font-semibold tracking-[0.16em] uppercase",
|
|
41
|
+
statusToneByConnection[status],
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
>
|
|
45
|
+
<span
|
|
46
|
+
className={cn(
|
|
47
|
+
"h-1.5 w-1.5 shrink-0 rounded-full",
|
|
48
|
+
statusDotToneByConnection[status],
|
|
49
|
+
)}
|
|
50
|
+
aria-hidden
|
|
51
|
+
/>
|
|
52
|
+
{statusLabelByConnection[status]}
|
|
53
|
+
</span>
|
|
54
|
+
);
|
|
55
|
+
};
|