@air-jam/sdk 0.1.4 → 0.9.1
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 +481 -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 +14 -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 +544 -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 +29 -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 +1737 -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 +123 -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-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-7UXSWCZZ.js +32 -0
- package/dist/chunk-7UXSWCZZ.js.map +1 -0
- package/dist/chunk-BE6Z4SIT.js +65 -0
- package/dist/chunk-BE6Z4SIT.js.map +1 -0
- package/dist/chunk-CABEUV65.js +184 -0
- package/dist/chunk-CABEUV65.js.map +1 -0
- package/dist/chunk-CEJ5RFSG.js +288 -0
- package/dist/chunk-CEJ5RFSG.js.map +1 -0
- package/dist/chunk-EDRQIOCV.js +25 -0
- package/dist/chunk-EDRQIOCV.js.map +1 -0
- package/dist/chunk-EVZJA6RN.js +140 -0
- package/dist/chunk-EVZJA6RN.js.map +1 -0
- package/dist/chunk-FAT2KJ3K.js +238 -0
- package/dist/chunk-FAT2KJ3K.js.map +1 -0
- package/dist/chunk-IKKDONQL.js +1 -0
- package/dist/chunk-IKKDONQL.js.map +1 -0
- package/dist/chunk-JEHV5C2X.js +249 -0
- package/dist/chunk-JEHV5C2X.js.map +1 -0
- package/dist/chunk-JO2HR5PV.js +43 -0
- package/dist/chunk-JO2HR5PV.js.map +1 -0
- package/dist/chunk-JTF47B56.js +1 -0
- package/dist/chunk-JTF47B56.js.map +1 -0
- package/dist/chunk-KXAFI5OP.js +193 -0
- package/dist/chunk-KXAFI5OP.js.map +1 -0
- package/dist/chunk-LIXPF4P6.js +22 -0
- package/dist/chunk-LIXPF4P6.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-NUJBMV3O.js +1435 -0
- package/dist/chunk-NUJBMV3O.js.map +1 -0
- package/dist/chunk-TGRTEWYV.js +195 -0
- package/dist/chunk-TGRTEWYV.js.map +1 -0
- package/dist/chunk-UWJOIVON.js +369 -0
- package/dist/chunk-UWJOIVON.js.map +1 -0
- package/dist/chunk-VKBMZHMQ.js +216 -0
- package/dist/chunk-VKBMZHMQ.js.map +1 -0
- package/dist/chunk-W2VK36RO.js +11 -0
- package/dist/chunk-W2VK36RO.js.map +1 -0
- package/dist/chunk-W3YA5BWR.js +126 -0
- package/dist/chunk-W3YA5BWR.js.map +1 -0
- package/dist/chunk-X24K52DG.js +12 -0
- package/dist/chunk-X24K52DG.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 +8730 -3426
- 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 -3196
- 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 +2620 -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/runtime-topology.cjs +405 -0
- package/dist/runtime-topology.cjs.map +1 -0
- package/dist/runtime-topology.d.cts +59 -0
- package/dist/runtime-topology.d.ts +59 -0
- package/dist/runtime-topology.js +31 -0
- package/dist/runtime-topology.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 +3061 -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 +1719 -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 +155 -10
- 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 -13
- 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 -161
- 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 -24
- 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/runtime-topology.ts +569 -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 -520
- 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/dist/ui.cjs
ADDED
|
@@ -0,0 +1,3061 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/ui.ts
|
|
31
|
+
var ui_exports = {};
|
|
32
|
+
__export(ui_exports, {
|
|
33
|
+
AIRJAM_DEFAULT_AVATAR_SEEDS: () => AIRJAM_DEFAULT_AVATAR_SEEDS,
|
|
34
|
+
Button: () => Button,
|
|
35
|
+
ConnectionStatusPill: () => ConnectionStatusPill,
|
|
36
|
+
ControllerPlayerNameField: () => ControllerPlayerNameField,
|
|
37
|
+
ControllerPrimaryAction: () => ControllerPrimaryAction,
|
|
38
|
+
HostMuteButton: () => HostMuteButton,
|
|
39
|
+
JoinQrOverlay: () => JoinQrOverlay,
|
|
40
|
+
JoinUrlActionButtons: () => JoinUrlActionButtons,
|
|
41
|
+
JoinUrlControls: () => JoinUrlControls,
|
|
42
|
+
JoinUrlField: () => JoinUrlField,
|
|
43
|
+
LifecycleActionGroup: () => LifecycleActionGroup,
|
|
44
|
+
PlayerAvatar: () => PlayerAvatar,
|
|
45
|
+
PlayerAvatarStrip: () => PlayerAvatarStrip,
|
|
46
|
+
RoomQrCode: () => RoomQrCode,
|
|
47
|
+
RuntimeShellHeader: () => RuntimeShellHeader,
|
|
48
|
+
Slider: () => Slider,
|
|
49
|
+
SurfaceViewport: () => SurfaceViewport,
|
|
50
|
+
VolumeControls: () => VolumeControls,
|
|
51
|
+
buttonVariants: () => buttonVariants,
|
|
52
|
+
getDiceBearAdventurerNeutralUrl: () => getDiceBearAdventurerNeutralUrl,
|
|
53
|
+
getPlayerAvatarImageUrl: () => getPlayerAvatarImageUrl,
|
|
54
|
+
resolvePlayerAvatarSeed: () => resolvePlayerAvatarSeed,
|
|
55
|
+
useControllerLifecycleIntents: () => useControllerLifecycleIntents,
|
|
56
|
+
useControllerLifecyclePermissions: () => useControllerLifecyclePermissions,
|
|
57
|
+
useControllerShellStatus: () => useControllerShellStatus,
|
|
58
|
+
useHostJoinControls: () => useHostJoinControls,
|
|
59
|
+
useLifecycleActionGroupModel: () => useLifecycleActionGroupModel
|
|
60
|
+
});
|
|
61
|
+
module.exports = __toCommonJS(ui_exports);
|
|
62
|
+
|
|
63
|
+
// src/utils/cn.ts
|
|
64
|
+
var import_clsx = require("clsx");
|
|
65
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
66
|
+
var cn = (...inputs) => (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
67
|
+
|
|
68
|
+
// src/components/connection-status-pill.tsx
|
|
69
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
70
|
+
var statusLabelByConnection = {
|
|
71
|
+
connected: "Live",
|
|
72
|
+
connecting: "Syncing",
|
|
73
|
+
reconnecting: "Syncing",
|
|
74
|
+
disconnected: "Offline",
|
|
75
|
+
idle: "Idle"
|
|
76
|
+
};
|
|
77
|
+
var statusToneByConnection = {
|
|
78
|
+
connected: "border-emerald-400/18 bg-emerald-400/8 text-emerald-50",
|
|
79
|
+
connecting: "border-amber-400/18 bg-amber-400/8 text-amber-50",
|
|
80
|
+
reconnecting: "border-amber-400/18 bg-amber-400/8 text-amber-50",
|
|
81
|
+
disconnected: "border-rose-400/18 bg-rose-400/8 text-rose-50",
|
|
82
|
+
idle: "border-white/10 bg-white/[0.05] text-white/78"
|
|
83
|
+
};
|
|
84
|
+
var statusDotToneByConnection = {
|
|
85
|
+
connected: "bg-emerald-300",
|
|
86
|
+
connecting: "bg-amber-300",
|
|
87
|
+
reconnecting: "bg-amber-300",
|
|
88
|
+
disconnected: "bg-rose-300",
|
|
89
|
+
idle: "bg-white/45"
|
|
90
|
+
};
|
|
91
|
+
var ConnectionStatusPill = ({
|
|
92
|
+
status,
|
|
93
|
+
className
|
|
94
|
+
}) => {
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
96
|
+
"span",
|
|
97
|
+
{
|
|
98
|
+
className: cn(
|
|
99
|
+
"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",
|
|
100
|
+
statusToneByConnection[status],
|
|
101
|
+
className
|
|
102
|
+
),
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
className: cn(
|
|
108
|
+
"h-1.5 w-1.5 shrink-0 rounded-full",
|
|
109
|
+
statusDotToneByConnection[status]
|
|
110
|
+
),
|
|
111
|
+
"aria-hidden": true
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
statusLabelByConnection[status]
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/components/controller-player-name-field.tsx
|
|
121
|
+
var import_react5 = require("react");
|
|
122
|
+
|
|
123
|
+
// src/hooks/use-air-jam-controller.ts
|
|
124
|
+
var import_react4 = require("react");
|
|
125
|
+
var import_zustand3 = require("zustand");
|
|
126
|
+
var import_shallow2 = require("zustand/react/shallow");
|
|
127
|
+
|
|
128
|
+
// src/runtime-topology.ts
|
|
129
|
+
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
130
|
+
"standalone-dev",
|
|
131
|
+
"standalone-secure",
|
|
132
|
+
"arcade-live",
|
|
133
|
+
"arcade-built",
|
|
134
|
+
"self-hosted-production",
|
|
135
|
+
"hosted-release"
|
|
136
|
+
]);
|
|
137
|
+
var SURFACE_ROLES = /* @__PURE__ */ new Set([
|
|
138
|
+
"host",
|
|
139
|
+
"controller",
|
|
140
|
+
"platform-host",
|
|
141
|
+
"platform-controller"
|
|
142
|
+
]);
|
|
143
|
+
var PROXY_STRATEGIES = /* @__PURE__ */ new Set([
|
|
144
|
+
"none",
|
|
145
|
+
"platform-proxy",
|
|
146
|
+
"dev-proxy"
|
|
147
|
+
]);
|
|
148
|
+
var AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX = "aj_topology_";
|
|
149
|
+
var REQUIRED_QUERY_KEYS = [
|
|
150
|
+
"runtime_mode",
|
|
151
|
+
"surface_role",
|
|
152
|
+
"app_origin",
|
|
153
|
+
"backend_origin",
|
|
154
|
+
"public_host",
|
|
155
|
+
"asset_base_path",
|
|
156
|
+
"secure_transport",
|
|
157
|
+
"embedded",
|
|
158
|
+
"proxy_strategy"
|
|
159
|
+
];
|
|
160
|
+
var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
161
|
+
var assertString = (value, fieldName) => {
|
|
162
|
+
if (typeof value !== "string") {
|
|
163
|
+
throw new Error(`Runtime topology field "${fieldName}" must be a string.`);
|
|
164
|
+
}
|
|
165
|
+
const normalized = value.trim();
|
|
166
|
+
if (!normalized) {
|
|
167
|
+
throw new Error(`Runtime topology field "${fieldName}" cannot be empty.`);
|
|
168
|
+
}
|
|
169
|
+
return normalized;
|
|
170
|
+
};
|
|
171
|
+
var assertBoolean = (value, fieldName) => {
|
|
172
|
+
if (typeof value !== "boolean") {
|
|
173
|
+
throw new Error(`Runtime topology field "${fieldName}" must be a boolean.`);
|
|
174
|
+
}
|
|
175
|
+
return value;
|
|
176
|
+
};
|
|
177
|
+
var assertUrl = (value, fieldName) => {
|
|
178
|
+
const normalized = assertString(value, fieldName);
|
|
179
|
+
const withScheme = normalized.includes("://") ? normalized : `http://${normalized}`;
|
|
180
|
+
let parsed;
|
|
181
|
+
try {
|
|
182
|
+
parsed = new URL(withScheme);
|
|
183
|
+
} catch {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Runtime topology field "${fieldName}" must be a valid absolute URL.`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Runtime topology field "${fieldName}" must use http or https.`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
parsed.pathname = "";
|
|
194
|
+
parsed.search = "";
|
|
195
|
+
parsed.hash = "";
|
|
196
|
+
return parsed.origin;
|
|
197
|
+
};
|
|
198
|
+
var normalizeAssetBasePath = (value) => {
|
|
199
|
+
if (value == null) {
|
|
200
|
+
return "/";
|
|
201
|
+
}
|
|
202
|
+
const normalized = assertString(value, "assetBasePath");
|
|
203
|
+
if (normalized === "/") {
|
|
204
|
+
return normalized;
|
|
205
|
+
}
|
|
206
|
+
const withLeadingSlash = normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
207
|
+
return withLeadingSlash.endsWith("/") && withLeadingSlash.length > 1 ? withLeadingSlash.slice(0, -1) : withLeadingSlash;
|
|
208
|
+
};
|
|
209
|
+
var fromBooleanParam = (value, fieldName) => {
|
|
210
|
+
if (value === "true") {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
if (value === "false") {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
throw new Error(
|
|
217
|
+
`Runtime topology query field "${fieldName}" must be "true" or "false".`
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
var resolveDefaultSocketOrigin = ({
|
|
221
|
+
proxyStrategy,
|
|
222
|
+
appOrigin,
|
|
223
|
+
backendOrigin
|
|
224
|
+
}) => {
|
|
225
|
+
if (proxyStrategy === "none") {
|
|
226
|
+
return backendOrigin;
|
|
227
|
+
}
|
|
228
|
+
return appOrigin;
|
|
229
|
+
};
|
|
230
|
+
var inferSecureTransport = ({
|
|
231
|
+
runtimeMode,
|
|
232
|
+
appOrigin,
|
|
233
|
+
backendOrigin,
|
|
234
|
+
socketOrigin,
|
|
235
|
+
publicHost
|
|
236
|
+
}) => {
|
|
237
|
+
if (runtimeMode === "standalone-secure") {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
return [appOrigin, backendOrigin, socketOrigin, publicHost].every(
|
|
241
|
+
(origin) => origin.startsWith("https://")
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
var resolveRuntimeTopology = (input) => {
|
|
245
|
+
if (!isObject(input)) {
|
|
246
|
+
throw new Error("Runtime topology input must be an object.");
|
|
247
|
+
}
|
|
248
|
+
const runtimeMode = assertString(
|
|
249
|
+
input.runtimeMode,
|
|
250
|
+
"runtimeMode"
|
|
251
|
+
);
|
|
252
|
+
if (!RUNTIME_MODES.has(runtimeMode)) {
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Unsupported runtime mode "${runtimeMode}". Use one of: ${Array.from(RUNTIME_MODES).join(", ")}.`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const surfaceRole = assertString(
|
|
258
|
+
input.surfaceRole,
|
|
259
|
+
"surfaceRole"
|
|
260
|
+
);
|
|
261
|
+
if (!SURFACE_ROLES.has(surfaceRole)) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
`Unsupported surface role "${surfaceRole}". Use one of: ${Array.from(SURFACE_ROLES).join(", ")}.`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const appOrigin = assertUrl(input.appOrigin, "appOrigin");
|
|
267
|
+
const backendOrigin = assertUrl(input.backendOrigin, "backendOrigin");
|
|
268
|
+
const proxyStrategy = input.proxyStrategy == null ? "none" : assertString(input.proxyStrategy, "proxyStrategy");
|
|
269
|
+
if (!PROXY_STRATEGIES.has(proxyStrategy)) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`Unsupported proxy strategy "${proxyStrategy}". Use one of: ${Array.from(PROXY_STRATEGIES).join(", ")}.`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
const socketOrigin = input.socketOrigin != null ? assertUrl(input.socketOrigin, "socketOrigin") : resolveDefaultSocketOrigin({ proxyStrategy, appOrigin, backendOrigin });
|
|
275
|
+
const publicHost = input.publicHost != null ? assertUrl(input.publicHost, "publicHost") : appOrigin;
|
|
276
|
+
const assetBasePath = normalizeAssetBasePath(input.assetBasePath);
|
|
277
|
+
const embedded = input.embedded == null ? false : assertBoolean(input.embedded, "embedded");
|
|
278
|
+
const embedParentOrigin = input.embedParentOrigin == null ? void 0 : assertUrl(input.embedParentOrigin, "embedParentOrigin");
|
|
279
|
+
if (embedded && !embedParentOrigin) {
|
|
280
|
+
throw new Error(
|
|
281
|
+
'Embedded runtimes must provide "embedParentOrigin" in their topology.'
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
if (!embedded && embedParentOrigin) {
|
|
285
|
+
throw new Error(
|
|
286
|
+
'Non-embedded runtimes cannot provide "embedParentOrigin" in their topology.'
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
const secureTransport = input.secureTransport == null ? inferSecureTransport({
|
|
290
|
+
runtimeMode,
|
|
291
|
+
appOrigin,
|
|
292
|
+
backendOrigin,
|
|
293
|
+
socketOrigin,
|
|
294
|
+
publicHost
|
|
295
|
+
}) : assertBoolean(input.secureTransport, "secureTransport");
|
|
296
|
+
return {
|
|
297
|
+
runtimeMode,
|
|
298
|
+
surfaceRole,
|
|
299
|
+
appOrigin,
|
|
300
|
+
backendOrigin,
|
|
301
|
+
socketOrigin,
|
|
302
|
+
publicHost,
|
|
303
|
+
assetBasePath,
|
|
304
|
+
secureTransport,
|
|
305
|
+
embedded,
|
|
306
|
+
...embedParentOrigin ? { embedParentOrigin } : {},
|
|
307
|
+
proxyStrategy
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
var parseRuntimeTopologyFromSearchParams = (params) => {
|
|
311
|
+
if (!(params instanceof URLSearchParams)) {
|
|
312
|
+
throw new Error(
|
|
313
|
+
"Runtime topology search param reader expects URLSearchParams."
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
const hasAnyTopologyParam = REQUIRED_QUERY_KEYS.some(
|
|
317
|
+
(key) => params.has(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}${key}`)
|
|
318
|
+
);
|
|
319
|
+
if (!hasAnyTopologyParam) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
const missing = REQUIRED_QUERY_KEYS.filter(
|
|
323
|
+
(key) => !params.has(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}${key}`)
|
|
324
|
+
);
|
|
325
|
+
if (missing.length > 0) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
`Runtime topology search params are incomplete. Missing: ${missing.join(", ")}.`
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
const embedParentOrigin = params.get(
|
|
331
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embed_parent_origin`
|
|
332
|
+
);
|
|
333
|
+
return resolveRuntimeTopology({
|
|
334
|
+
runtimeMode: params.get(
|
|
335
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}runtime_mode`
|
|
336
|
+
),
|
|
337
|
+
surfaceRole: params.get(
|
|
338
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}surface_role`
|
|
339
|
+
),
|
|
340
|
+
appOrigin: params.get(
|
|
341
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}app_origin`
|
|
342
|
+
),
|
|
343
|
+
backendOrigin: params.get(
|
|
344
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}backend_origin`
|
|
345
|
+
),
|
|
346
|
+
socketOrigin: params.get(
|
|
347
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}socket_origin`
|
|
348
|
+
),
|
|
349
|
+
publicHost: params.get(
|
|
350
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}public_host`
|
|
351
|
+
),
|
|
352
|
+
assetBasePath: params.get(
|
|
353
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}asset_base_path`
|
|
354
|
+
),
|
|
355
|
+
secureTransport: fromBooleanParam(
|
|
356
|
+
params.get(
|
|
357
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}secure_transport`
|
|
358
|
+
),
|
|
359
|
+
"secure_transport"
|
|
360
|
+
),
|
|
361
|
+
embedded: fromBooleanParam(
|
|
362
|
+
params.get(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embedded`),
|
|
363
|
+
"embedded"
|
|
364
|
+
),
|
|
365
|
+
proxyStrategy: params.get(
|
|
366
|
+
`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}proxy_strategy`
|
|
367
|
+
),
|
|
368
|
+
...embedParentOrigin ? { embedParentOrigin } : {}
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// src/context/air-jam-context.tsx
|
|
373
|
+
var import_react = require("react");
|
|
374
|
+
var import_zustand2 = require("zustand");
|
|
375
|
+
var import_shallow = require("zustand/react/shallow");
|
|
376
|
+
|
|
377
|
+
// src/diagnostics.ts
|
|
378
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
379
|
+
var lastEmissionByKey = /* @__PURE__ */ new Map();
|
|
380
|
+
var DIAGNOSTIC_THROTTLE_MS = 1500;
|
|
381
|
+
var diagnosticsEnabledOverride = null;
|
|
382
|
+
var shouldEmitDiagnostics = () => {
|
|
383
|
+
if (diagnosticsEnabledOverride !== null) {
|
|
384
|
+
return diagnosticsEnabledOverride;
|
|
385
|
+
}
|
|
386
|
+
const nodeEnv = globalThis.process?.env?.NODE_ENV;
|
|
387
|
+
if (typeof nodeEnv === "string") {
|
|
388
|
+
return nodeEnv !== "production";
|
|
389
|
+
}
|
|
390
|
+
return true;
|
|
391
|
+
};
|
|
392
|
+
var toConsolePrefix = (code) => `[AirJam][${code}]`;
|
|
393
|
+
var emitAirJamDiagnostic = (input) => {
|
|
394
|
+
if (!shouldEmitDiagnostics()) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const now = Date.now();
|
|
398
|
+
const key = `${input.code}|${input.message}`;
|
|
399
|
+
const last = lastEmissionByKey.get(key);
|
|
400
|
+
if (last && now - last < DIAGNOSTIC_THROTTLE_MS) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
lastEmissionByKey.set(key, now);
|
|
404
|
+
const diagnostic = {
|
|
405
|
+
...input,
|
|
406
|
+
timestamp: now
|
|
407
|
+
};
|
|
408
|
+
for (const listener of listeners) {
|
|
409
|
+
listener(diagnostic);
|
|
410
|
+
}
|
|
411
|
+
const logger = input.severity === "error" ? console.error : console.warn;
|
|
412
|
+
if (input.details) {
|
|
413
|
+
logger(`${toConsolePrefix(input.code)} ${input.message}`, input.details);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
logger(`${toConsolePrefix(input.code)} ${input.message}`);
|
|
417
|
+
};
|
|
418
|
+
var createAirJamDiagnosticError = (code, message, details) => {
|
|
419
|
+
emitAirJamDiagnostic({
|
|
420
|
+
code,
|
|
421
|
+
severity: "error",
|
|
422
|
+
message,
|
|
423
|
+
details
|
|
424
|
+
});
|
|
425
|
+
const error = new Error(`${toConsolePrefix(code)} ${message}`);
|
|
426
|
+
Object.defineProperty(error, "code", {
|
|
427
|
+
value: code,
|
|
428
|
+
enumerable: true
|
|
429
|
+
});
|
|
430
|
+
return error;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
// src/protocol/controller.ts
|
|
434
|
+
var import_zod2 = require("zod");
|
|
435
|
+
|
|
436
|
+
// src/protocol/core.ts
|
|
437
|
+
var import_zod = require("zod");
|
|
438
|
+
var roomCodeSchema = import_zod.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, { message: "room code must contain only A-Z or 0-9" });
|
|
439
|
+
|
|
440
|
+
// src/protocol/controller.ts
|
|
441
|
+
var controllerInputSchema = import_zod2.z.object({
|
|
442
|
+
roomId: roomCodeSchema,
|
|
443
|
+
controllerId: import_zod2.z.string().min(3),
|
|
444
|
+
input: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown())
|
|
445
|
+
});
|
|
446
|
+
var controllerOrientationSchema = import_zod2.z.enum(["portrait", "landscape"]);
|
|
447
|
+
var controllerSourceSchema = import_zod2.z.enum(["phone", "preview", "virtual"]);
|
|
448
|
+
var controllerStateSchema = import_zod2.z.object({
|
|
449
|
+
roomId: roomCodeSchema,
|
|
450
|
+
state: import_zod2.z.object({
|
|
451
|
+
orientation: controllerOrientationSchema.optional(),
|
|
452
|
+
message: import_zod2.z.string().optional(),
|
|
453
|
+
roomSettings: import_zod2.z.object({
|
|
454
|
+
audio: import_zod2.z.object({
|
|
455
|
+
masterVolume: import_zod2.z.number().min(0).max(1),
|
|
456
|
+
musicVolume: import_zod2.z.number().min(0).max(1),
|
|
457
|
+
sfxVolume: import_zod2.z.number().min(0).max(1)
|
|
458
|
+
}),
|
|
459
|
+
previewControllers: import_zod2.z.object({
|
|
460
|
+
activeOpacity: import_zod2.z.number().min(0).max(1)
|
|
461
|
+
})
|
|
462
|
+
}).optional(),
|
|
463
|
+
runtimeState: import_zod2.z.enum(["paused", "playing"]).optional(),
|
|
464
|
+
stateVersion: import_zod2.z.number().int().nonnegative().optional()
|
|
465
|
+
})
|
|
466
|
+
});
|
|
467
|
+
var controllerJoinSchema = import_zod2.z.object({
|
|
468
|
+
roomId: roomCodeSchema,
|
|
469
|
+
controllerId: import_zod2.z.string().min(3),
|
|
470
|
+
/**
|
|
471
|
+
* Stable local controller device identity used as a reconnect hint.
|
|
472
|
+
* Older clients may omit this and fall back to controllerId-only behavior.
|
|
473
|
+
*/
|
|
474
|
+
deviceId: import_zod2.z.string().min(8).max(128).optional(),
|
|
475
|
+
nickname: import_zod2.z.string().trim().min(1).max(24).optional(),
|
|
476
|
+
/** Preset avatar key (platform-defined); optional at join. */
|
|
477
|
+
avatarId: import_zod2.z.string().trim().min(1).max(48).optional(),
|
|
478
|
+
capabilityToken: import_zod2.z.string().min(1).optional()
|
|
479
|
+
});
|
|
480
|
+
var controllerLeaveSchema = import_zod2.z.object({
|
|
481
|
+
roomId: roomCodeSchema,
|
|
482
|
+
controllerId: import_zod2.z.string().min(3)
|
|
483
|
+
});
|
|
484
|
+
var controllerSystemSchema = import_zod2.z.object({
|
|
485
|
+
roomId: roomCodeSchema,
|
|
486
|
+
command: import_zod2.z.enum(["exit", "pause", "resume"])
|
|
487
|
+
});
|
|
488
|
+
var playerProfilePatchSchema = import_zod2.z.object({
|
|
489
|
+
label: import_zod2.z.string().trim().min(1).max(24).optional(),
|
|
490
|
+
avatarId: import_zod2.z.string().trim().min(1).max(48).optional()
|
|
491
|
+
}).strict();
|
|
492
|
+
var controllerUpdatePlayerProfileSchema = import_zod2.z.object({
|
|
493
|
+
roomId: roomCodeSchema,
|
|
494
|
+
controllerId: import_zod2.z.string().min(3),
|
|
495
|
+
patch: playerProfilePatchSchema
|
|
496
|
+
}).refine(
|
|
497
|
+
(data) => data.patch.label !== void 0 || data.patch.avatarId !== void 0,
|
|
498
|
+
{ message: "patch must include at least one field" }
|
|
499
|
+
);
|
|
500
|
+
var controllerPrivilegedGrantSchema = import_zod2.z.enum([
|
|
501
|
+
"system",
|
|
502
|
+
"play_sound",
|
|
503
|
+
"action_rpc"
|
|
504
|
+
]);
|
|
505
|
+
var controllerPrivilegedCapabilitySchema = import_zod2.z.object({
|
|
506
|
+
token: import_zod2.z.string().min(1),
|
|
507
|
+
expiresAt: import_zod2.z.number().int().positive(),
|
|
508
|
+
grants: import_zod2.z.array(controllerPrivilegedGrantSchema).min(1)
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
// src/protocol/dev-log-events.ts
|
|
512
|
+
var AIRJAM_DEV_LOG_EVENTS = {
|
|
513
|
+
server: {
|
|
514
|
+
started: "server.started",
|
|
515
|
+
startupFailed: "server.startup.failed"
|
|
516
|
+
},
|
|
517
|
+
socket: {
|
|
518
|
+
connected: "socket.connected",
|
|
519
|
+
disconnected: "socket.disconnected"
|
|
520
|
+
},
|
|
521
|
+
auth: {
|
|
522
|
+
modeDisabled: "auth.mode.disabled",
|
|
523
|
+
modeMasterKey: "auth.mode.master_key",
|
|
524
|
+
modeDatabaseAndHostGrant: "auth.mode.database_and_host_grant",
|
|
525
|
+
modeDatabase: "auth.mode.database",
|
|
526
|
+
modeHostGrantOnly: "auth.mode.host_grant_only",
|
|
527
|
+
backendMissing: "auth.backend.missing",
|
|
528
|
+
appIdLastUsedAtUpdateFailed: "auth.app_id_last_used_at_update.failed",
|
|
529
|
+
appIdVerificationDatabaseError: "auth.app_id_verification.database_error"
|
|
530
|
+
},
|
|
531
|
+
browser: {
|
|
532
|
+
logSessionStarted: "browser.log_session.started",
|
|
533
|
+
logBatchReceived: "browser.log_batch.received",
|
|
534
|
+
console: "browser.console",
|
|
535
|
+
windowError: "browser.window_error",
|
|
536
|
+
unhandledRejection: "browser.unhandled_rejection",
|
|
537
|
+
diagnostic: "browser.diagnostic",
|
|
538
|
+
runtime: "browser.runtime"
|
|
539
|
+
},
|
|
540
|
+
runtime: {
|
|
541
|
+
providerMounted: "runtime.provider.mounted",
|
|
542
|
+
providerUnmounted: "runtime.provider.unmounted",
|
|
543
|
+
windowBeforeUnload: "runtime.window.beforeunload",
|
|
544
|
+
windowPageHide: "runtime.window.pagehide",
|
|
545
|
+
socketConnected: "runtime.socket.connected",
|
|
546
|
+
socketDisconnected: "runtime.socket.disconnected",
|
|
547
|
+
socketConnectError: "runtime.socket.connect_error",
|
|
548
|
+
hostCreateRoomRequested: "runtime.host.create_room.requested",
|
|
549
|
+
hostReconnectRequested: "runtime.host.reconnect.requested",
|
|
550
|
+
hostReconnectRetryScheduled: "runtime.host.reconnect.retry_scheduled",
|
|
551
|
+
hostResetRoomRequested: "runtime.host.reset_room.requested",
|
|
552
|
+
hostStateReceived: "runtime.host.state.received",
|
|
553
|
+
controllerJoinRequested: "runtime.controller.join.requested",
|
|
554
|
+
controllerStateReceived: "runtime.controller.state.received",
|
|
555
|
+
phaseTransition: "runtime.phase.transition",
|
|
556
|
+
stateVersionReceived: "runtime.state_version.received",
|
|
557
|
+
invariantViolation: "runtime.invariant.violation",
|
|
558
|
+
embeddedBridgeRequested: "runtime.embedded_bridge.requested",
|
|
559
|
+
embeddedBridgeAttached: "runtime.embedded_bridge.attached",
|
|
560
|
+
embeddedBridgeRejected: "runtime.embedded_bridge.rejected",
|
|
561
|
+
embeddedBridgeClosed: "runtime.embedded_bridge.closed",
|
|
562
|
+
browserLogSinkFailure: "runtime.browser_log_sink.failure"
|
|
563
|
+
},
|
|
564
|
+
host: {
|
|
565
|
+
lifecycleRejected: "host.lifecycle.rejected",
|
|
566
|
+
bootstrapVerified: "host.bootstrap.verified",
|
|
567
|
+
bootstrapRejected: "host.bootstrap.rejected",
|
|
568
|
+
disconnectPendingRoomClose: "host.disconnect.pending_room_close",
|
|
569
|
+
disconnectRoomClosed: "host.disconnect.room_closed",
|
|
570
|
+
registerSystemAccepted: "host.register_system.accepted",
|
|
571
|
+
registerSystemRejected: "host.register_system.rejected",
|
|
572
|
+
createRoomAccepted: "host.create_room.accepted",
|
|
573
|
+
createRoomRejected: "host.create_room.rejected",
|
|
574
|
+
reconnectAccepted: "host.reconnect.accepted",
|
|
575
|
+
reconnectRejected: "host.reconnect.rejected",
|
|
576
|
+
resetRoomAccepted: "host.reset_room.accepted",
|
|
577
|
+
resetRoomRejected: "host.reset_room.rejected",
|
|
578
|
+
systemAccepted: "host.system.accepted",
|
|
579
|
+
systemRejected: "host.system.rejected",
|
|
580
|
+
stateRejected: "host.state.rejected",
|
|
581
|
+
signalRejected: "host.signal.rejected",
|
|
582
|
+
playSoundRejected: "host.play_sound.rejected",
|
|
583
|
+
stateBroadcastSummary: "host.state_broadcast.summary",
|
|
584
|
+
reconnectStateReconcile: "host.reconnect.state_reconcile",
|
|
585
|
+
stateSyncSummary: "host.state_sync.summary",
|
|
586
|
+
stateSyncRejected: "host.state_sync.rejected"
|
|
587
|
+
},
|
|
588
|
+
controller: {
|
|
589
|
+
joinAccepted: "controller.join.accepted",
|
|
590
|
+
joinRejected: "controller.join.rejected",
|
|
591
|
+
resumeAccepted: "controller.resume.accepted",
|
|
592
|
+
disconnectPendingResume: "controller.disconnect.pending_resume",
|
|
593
|
+
disconnectLeaseExpired: "controller.disconnect.lease_expired",
|
|
594
|
+
disconnectApplied: "controller.disconnect.applied",
|
|
595
|
+
profileUpdateAccepted: "controller.profile_update.accepted",
|
|
596
|
+
profileUpdateRejected: "controller.profile_update.rejected",
|
|
597
|
+
leaveAccepted: "controller.leave.accepted",
|
|
598
|
+
leaveRejected: "controller.leave.rejected",
|
|
599
|
+
inputSummary: "controller.input.summary",
|
|
600
|
+
inputDroppedSummary: "controller.input_dropped.summary",
|
|
601
|
+
inputRejected: "controller.input.rejected",
|
|
602
|
+
systemAccepted: "controller.system.accepted",
|
|
603
|
+
systemRejected: "controller.system.rejected",
|
|
604
|
+
playSoundRejected: "controller.play_sound.rejected",
|
|
605
|
+
actionRpcSummary: "controller.action_rpc.summary",
|
|
606
|
+
actionRpcRejected: "controller.action_rpc.rejected"
|
|
607
|
+
},
|
|
608
|
+
system: {
|
|
609
|
+
launchGameAccepted: "system.launch_game.accepted",
|
|
610
|
+
launchGameRejected: "system.launch_game.rejected",
|
|
611
|
+
closeGameAccepted: "system.close_game.accepted",
|
|
612
|
+
closeGameRejected: "system.close_game.rejected"
|
|
613
|
+
},
|
|
614
|
+
childHost: {
|
|
615
|
+
joinAccepted: "child_host.join.accepted",
|
|
616
|
+
joinRejected: "child_host.join.rejected",
|
|
617
|
+
disconnectPendingSystemFocus: "child_host.disconnect.pending_system_focus",
|
|
618
|
+
disconnectSystemFocusRestored: "child_host.disconnect.system_focus_restored"
|
|
619
|
+
},
|
|
620
|
+
embeddedGame: {
|
|
621
|
+
activateAccepted: "embedded_game.activate.accepted",
|
|
622
|
+
activateRejected: "embedded_game.activate.rejected"
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
var AIRJAM_BROWSER_LOG_EVENT_BY_SOURCE = {
|
|
626
|
+
console: AIRJAM_DEV_LOG_EVENTS.browser.console,
|
|
627
|
+
"window-error": AIRJAM_DEV_LOG_EVENTS.browser.windowError,
|
|
628
|
+
unhandledrejection: AIRJAM_DEV_LOG_EVENTS.browser.unhandledRejection,
|
|
629
|
+
diagnostic: AIRJAM_DEV_LOG_EVENTS.browser.diagnostic,
|
|
630
|
+
runtime: AIRJAM_DEV_LOG_EVENTS.browser.runtime
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
// src/protocol/host.ts
|
|
634
|
+
var import_zod3 = require("zod");
|
|
635
|
+
var hostSessionKindSchema = import_zod3.z.enum(["game", "system"]);
|
|
636
|
+
var childHostCapabilitySchema = import_zod3.z.object({
|
|
637
|
+
token: import_zod3.z.string().min(1),
|
|
638
|
+
expiresAt: import_zod3.z.number().int().positive()
|
|
639
|
+
});
|
|
640
|
+
var hostBootstrapSchema = import_zod3.z.object({
|
|
641
|
+
appId: import_zod3.z.string().optional(),
|
|
642
|
+
hostGrant: import_zod3.z.string().min(1).optional(),
|
|
643
|
+
hostSessionKind: hostSessionKindSchema.default("system")
|
|
644
|
+
});
|
|
645
|
+
var hostRegisterSystemSchema = import_zod3.z.object({
|
|
646
|
+
roomId: roomCodeSchema
|
|
647
|
+
});
|
|
648
|
+
var systemLaunchGameSchema = import_zod3.z.object({
|
|
649
|
+
roomId: roomCodeSchema,
|
|
650
|
+
gameId: import_zod3.z.string()
|
|
651
|
+
});
|
|
652
|
+
var hostJoinAsChildSchema = import_zod3.z.object({
|
|
653
|
+
roomId: roomCodeSchema,
|
|
654
|
+
capabilityToken: import_zod3.z.string().min(1)
|
|
655
|
+
});
|
|
656
|
+
var hostActivateEmbeddedGameSchema = import_zod3.z.object({
|
|
657
|
+
roomId: roomCodeSchema,
|
|
658
|
+
capabilityToken: import_zod3.z.string().min(1)
|
|
659
|
+
});
|
|
660
|
+
var hostCreateRoomSchema = import_zod3.z.object({
|
|
661
|
+
maxPlayers: import_zod3.z.number().int().min(1).max(16).default(8)
|
|
662
|
+
});
|
|
663
|
+
var hostReconnectSchema = import_zod3.z.object({
|
|
664
|
+
roomId: roomCodeSchema
|
|
665
|
+
});
|
|
666
|
+
var hostResetRoomSchema = import_zod3.z.object({
|
|
667
|
+
roomId: roomCodeSchema
|
|
668
|
+
});
|
|
669
|
+
var hostRemoveControllerSchema = import_zod3.z.object({
|
|
670
|
+
roomId: roomCodeSchema,
|
|
671
|
+
controllerId: import_zod3.z.string().min(3)
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
// src/protocol/host-grant.ts
|
|
675
|
+
var import_zod4 = require("zod");
|
|
676
|
+
var hostGrantScopeSchema = import_zod4.z.literal("host:bootstrap");
|
|
677
|
+
var hostGrantClaimsSchema = import_zod4.z.object({
|
|
678
|
+
typ: import_zod4.z.literal("airjam.host_grant.v1"),
|
|
679
|
+
appId: import_zod4.z.string().min(1),
|
|
680
|
+
exp: import_zod4.z.number().int().positive(),
|
|
681
|
+
iat: import_zod4.z.number().int().positive().optional(),
|
|
682
|
+
scopes: import_zod4.z.array(hostGrantScopeSchema).min(1).default(["host:bootstrap"]),
|
|
683
|
+
origins: import_zod4.z.array(import_zod4.z.string().min(1)).optional()
|
|
684
|
+
});
|
|
685
|
+
var encoder = new TextEncoder();
|
|
686
|
+
var decoder = new TextDecoder();
|
|
687
|
+
|
|
688
|
+
// src/protocol/sync.ts
|
|
689
|
+
var import_zod5 = require("zod");
|
|
690
|
+
var stateSyncRequestIdSchema = import_zod5.z.string().trim().min(1).max(128);
|
|
691
|
+
var airJamActionPayloadSchema = import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown());
|
|
692
|
+
var controllerActionRpcSchema = import_zod5.z.object({
|
|
693
|
+
roomId: roomCodeSchema,
|
|
694
|
+
actionName: import_zod5.z.string().trim().min(1),
|
|
695
|
+
payload: import_zod5.z.union([airJamActionPayloadSchema, import_zod5.z.undefined()]).optional(),
|
|
696
|
+
storeDomain: import_zod5.z.string().trim().min(1).max(128)
|
|
697
|
+
}).strict();
|
|
698
|
+
var hostActionRpcSchema = import_zod5.z.object({
|
|
699
|
+
roomId: roomCodeSchema,
|
|
700
|
+
actionName: import_zod5.z.string().trim().min(1),
|
|
701
|
+
payload: import_zod5.z.union([airJamActionPayloadSchema, import_zod5.z.undefined()]).optional(),
|
|
702
|
+
storeDomain: import_zod5.z.string().trim().min(1).max(128)
|
|
703
|
+
}).strict();
|
|
704
|
+
var hostStateSyncSchema = import_zod5.z.object({
|
|
705
|
+
roomId: roomCodeSchema,
|
|
706
|
+
data: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()),
|
|
707
|
+
storeDomain: import_zod5.z.string().trim().min(1).max(128),
|
|
708
|
+
revision: import_zod5.z.number().int().nonnegative(),
|
|
709
|
+
requestId: stateSyncRequestIdSchema.optional()
|
|
710
|
+
}).strict();
|
|
711
|
+
var controllerStateSyncRequestSchema = import_zod5.z.object({
|
|
712
|
+
roomId: roomCodeSchema,
|
|
713
|
+
storeDomain: import_zod5.z.string().trim().min(1).max(128),
|
|
714
|
+
requestId: stateSyncRequestIdSchema.optional()
|
|
715
|
+
}).strict();
|
|
716
|
+
|
|
717
|
+
// src/protocol/url-policy.ts
|
|
718
|
+
var import_zod6 = require("zod");
|
|
719
|
+
var ALLOWED_RUNTIME_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
720
|
+
var parseRuntimeUrl = (value) => {
|
|
721
|
+
try {
|
|
722
|
+
const parsed = new URL(value);
|
|
723
|
+
if (!ALLOWED_RUNTIME_PROTOCOLS.has(parsed.protocol)) {
|
|
724
|
+
return null;
|
|
725
|
+
}
|
|
726
|
+
if (parsed.username || parsed.password) {
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
return parsed;
|
|
730
|
+
} catch {
|
|
731
|
+
return null;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
var runtimeUrlSchema = import_zod6.z.string().trim().min(1).refine((value) => parseRuntimeUrl(value) !== null, {
|
|
735
|
+
message: "URL must be a valid http(s) URL without embedded credentials."
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
// src/state/connection-store.ts
|
|
739
|
+
var import_zustand = require("zustand");
|
|
740
|
+
|
|
741
|
+
// src/settings/platform-settings.ts
|
|
742
|
+
var DEFAULT_PLATFORM_SETTINGS = {
|
|
743
|
+
audio: {
|
|
744
|
+
masterVolume: 1,
|
|
745
|
+
musicVolume: 0.8,
|
|
746
|
+
sfxVolume: 1
|
|
747
|
+
},
|
|
748
|
+
accessibility: {
|
|
749
|
+
reducedMotion: false,
|
|
750
|
+
highContrast: false
|
|
751
|
+
},
|
|
752
|
+
feedback: {
|
|
753
|
+
hapticsEnabled: true
|
|
754
|
+
},
|
|
755
|
+
previewControllers: {
|
|
756
|
+
activeOpacity: 1
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
var DEFAULT_ROOM_PLATFORM_SETTINGS = {
|
|
760
|
+
audio: DEFAULT_PLATFORM_SETTINGS.audio,
|
|
761
|
+
previewControllers: DEFAULT_PLATFORM_SETTINGS.previewControllers
|
|
762
|
+
};
|
|
763
|
+
var clamp01 = (value) => Math.max(0, Math.min(1, value));
|
|
764
|
+
var getEffectiveAudioVolume = (settings, category) => {
|
|
765
|
+
const categoryVolume = category === "music" ? settings.musicVolume : settings.sfxVolume;
|
|
766
|
+
return clamp01(settings.masterVolume) * clamp01(categoryVolume);
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
// src/context/socket-manager.ts
|
|
770
|
+
var import_socket = require("socket.io-client");
|
|
771
|
+
|
|
772
|
+
// src/context/air-jam-context.tsx
|
|
773
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
774
|
+
var AirJamContext = (0, import_react.createContext)(null);
|
|
775
|
+
var useAirJamContext = () => {
|
|
776
|
+
const context = (0, import_react.useContext)(AirJamContext);
|
|
777
|
+
if (!context) {
|
|
778
|
+
throw createAirJamDiagnosticError(
|
|
779
|
+
"AJ_MISSING_SESSION_PROVIDER",
|
|
780
|
+
"useAirJamContext must be used within a session provider. Wrap your app or component tree with <HostSessionProvider> or <ControllerSessionProvider>."
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
return context;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
// src/context/session-scope.ts
|
|
787
|
+
var import_react2 = require("react");
|
|
788
|
+
var SessionScopeContext = (0, import_react2.createContext)("unscoped");
|
|
789
|
+
var RuntimeOwnerRegistryContext = (0, import_react2.createContext)(null);
|
|
790
|
+
var useSessionScope = () => {
|
|
791
|
+
return (0, import_react2.useContext)(SessionScopeContext);
|
|
792
|
+
};
|
|
793
|
+
var useAssertSessionScope = (expectedScope, hookName) => {
|
|
794
|
+
const scope = useSessionScope();
|
|
795
|
+
if (scope === expectedScope) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const expectedProviderName = expectedScope === "host" ? "HostSessionProvider" : "ControllerSessionProvider";
|
|
799
|
+
throw createAirJamDiagnosticError(
|
|
800
|
+
"AJ_SCOPE_MISMATCH",
|
|
801
|
+
`${hookName} requires ${expectedProviderName} when using scoped providers. Received scope "${scope}".`,
|
|
802
|
+
{
|
|
803
|
+
hookName,
|
|
804
|
+
expectedScope,
|
|
805
|
+
receivedScope: scope
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
// src/runtime/runtime-owner-contexts.tsx
|
|
811
|
+
var import_react3 = require("react");
|
|
812
|
+
var hostRuntimeContext = (0, import_react3.createContext)(null);
|
|
813
|
+
var controllerRuntimeContext = (0, import_react3.createContext)(null);
|
|
814
|
+
|
|
815
|
+
// src/hooks/use-air-jam-controller.ts
|
|
816
|
+
var toControllerState = (state) => {
|
|
817
|
+
const selfPlayer = state.controllerId ? state.players.find((player) => player.id === state.controllerId) ?? null : null;
|
|
818
|
+
return {
|
|
819
|
+
roomId: state.roomId,
|
|
820
|
+
controllerId: state.controllerId,
|
|
821
|
+
connectionStatus: state.connectionStatus,
|
|
822
|
+
lastError: state.lastError,
|
|
823
|
+
runtimeState: state.runtimeState,
|
|
824
|
+
controllerOrientation: state.controllerOrientation,
|
|
825
|
+
stateMessage: state.stateMessage,
|
|
826
|
+
roomSettings: state.roomSettings,
|
|
827
|
+
players: state.players,
|
|
828
|
+
selfPlayer
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
function useAirJamController(selector) {
|
|
832
|
+
useAssertSessionScope("controller", "useAirJamController");
|
|
833
|
+
const { store } = useAirJamContext();
|
|
834
|
+
const selectedState = (0, import_zustand3.useStore)(
|
|
835
|
+
store,
|
|
836
|
+
(0, import_shallow2.useShallow)((state) => {
|
|
837
|
+
const controllerState = toControllerState(state);
|
|
838
|
+
return selector ? selector(controllerState) : controllerState;
|
|
839
|
+
})
|
|
840
|
+
);
|
|
841
|
+
const runtime = (0, import_react4.useContext)(
|
|
842
|
+
controllerRuntimeContext
|
|
843
|
+
);
|
|
844
|
+
if (!runtime) {
|
|
845
|
+
throw createAirJamDiagnosticError(
|
|
846
|
+
"AJ_SCOPE_MISMATCH",
|
|
847
|
+
"useAirJamController requires a mounted controller runtime boundary. Wrap the controller tree with <AirJamControllerRuntime> or <airjam.Controller> before reading controller state.",
|
|
848
|
+
{
|
|
849
|
+
hookName: "useAirJamController",
|
|
850
|
+
expectedScope: "controller",
|
|
851
|
+
receivedScope: "controller"
|
|
852
|
+
}
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
if (selector) {
|
|
856
|
+
return selectedState;
|
|
857
|
+
}
|
|
858
|
+
return {
|
|
859
|
+
...selectedState,
|
|
860
|
+
...runtime
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// src/components/controller-player-name-field.tsx
|
|
865
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
866
|
+
var LABEL_MAX = 24;
|
|
867
|
+
var DEFAULT_DEBOUNCE_MS = 400;
|
|
868
|
+
var ControllerPlayerNameField = ({
|
|
869
|
+
fieldLabel = "Your name",
|
|
870
|
+
className,
|
|
871
|
+
labelClassName,
|
|
872
|
+
inputClassName,
|
|
873
|
+
debounceMs = DEFAULT_DEBOUNCE_MS
|
|
874
|
+
}) => {
|
|
875
|
+
const controller = useAirJamController();
|
|
876
|
+
const [local, setLocal] = (0, import_react5.useState)("");
|
|
877
|
+
const inputRef = (0, import_react5.useRef)(null);
|
|
878
|
+
const debounceTimerRef = (0, import_react5.useRef)(null);
|
|
879
|
+
const nextPlayerLabel = controller.selfPlayer?.label?.trim() ?? "";
|
|
880
|
+
(0, import_react5.useEffect)(() => {
|
|
881
|
+
if (inputRef.current === document.activeElement) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
setLocal(nextPlayerLabel);
|
|
885
|
+
}, [controller.controllerId, nextPlayerLabel]);
|
|
886
|
+
(0, import_react5.useEffect)(
|
|
887
|
+
() => () => {
|
|
888
|
+
if (debounceTimerRef.current !== null) {
|
|
889
|
+
clearTimeout(debounceTimerRef.current);
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
[]
|
|
893
|
+
);
|
|
894
|
+
const pushRoomName = (0, import_react5.useCallback)(
|
|
895
|
+
(raw) => {
|
|
896
|
+
const trimmed = raw.trim().slice(0, LABEL_MAX);
|
|
897
|
+
if (trimmed.length < 1) {
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
controller.setNickname(trimmed);
|
|
901
|
+
void controller.updatePlayerProfile({ label: trimmed });
|
|
902
|
+
},
|
|
903
|
+
[controller]
|
|
904
|
+
);
|
|
905
|
+
const schedulePush = (0, import_react5.useCallback)(
|
|
906
|
+
(raw) => {
|
|
907
|
+
if (debounceTimerRef.current !== null) {
|
|
908
|
+
clearTimeout(debounceTimerRef.current);
|
|
909
|
+
}
|
|
910
|
+
debounceTimerRef.current = setTimeout(() => {
|
|
911
|
+
debounceTimerRef.current = null;
|
|
912
|
+
pushRoomName(raw);
|
|
913
|
+
}, debounceMs);
|
|
914
|
+
},
|
|
915
|
+
[debounceMs, pushRoomName]
|
|
916
|
+
);
|
|
917
|
+
const connected = controller.connectionStatus === "connected";
|
|
918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: cn("min-w-0", className), children: [
|
|
919
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
920
|
+
"label",
|
|
921
|
+
{
|
|
922
|
+
className: cn("mb-1 block", labelClassName),
|
|
923
|
+
htmlFor: "airjam-controller-player-name",
|
|
924
|
+
children: fieldLabel
|
|
925
|
+
}
|
|
926
|
+
),
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
928
|
+
"input",
|
|
929
|
+
{
|
|
930
|
+
ref: inputRef,
|
|
931
|
+
id: "airjam-controller-player-name",
|
|
932
|
+
type: "text",
|
|
933
|
+
name: "airjam-controller-player-name",
|
|
934
|
+
autoComplete: "nickname",
|
|
935
|
+
enterKeyHint: "done",
|
|
936
|
+
maxLength: LABEL_MAX,
|
|
937
|
+
disabled: !connected,
|
|
938
|
+
value: local,
|
|
939
|
+
placeholder: connected ? "Enter name" : "Connect to edit",
|
|
940
|
+
className: cn(inputClassName),
|
|
941
|
+
onChange: (event) => {
|
|
942
|
+
const next = event.target.value.slice(0, LABEL_MAX);
|
|
943
|
+
setLocal(next);
|
|
944
|
+
schedulePush(next);
|
|
945
|
+
},
|
|
946
|
+
onBlur: () => {
|
|
947
|
+
if (debounceTimerRef.current !== null) {
|
|
948
|
+
clearTimeout(debounceTimerRef.current);
|
|
949
|
+
debounceTimerRef.current = null;
|
|
950
|
+
}
|
|
951
|
+
const trimmed = local.trim();
|
|
952
|
+
if (trimmed.length < 1) {
|
|
953
|
+
setLocal(nextPlayerLabel);
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
pushRoomName(local);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
)
|
|
960
|
+
] });
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
// src/components/ui/button.tsx
|
|
964
|
+
var import_react_slot = require("@radix-ui/react-slot");
|
|
965
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
966
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
967
|
+
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
968
|
+
"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 aria-invalid:border-destructive",
|
|
969
|
+
{
|
|
970
|
+
variants: {
|
|
971
|
+
variant: {
|
|
972
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
973
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20",
|
|
974
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
975
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
976
|
+
ghost: "text-foreground hover:bg-accent hover:text-accent-foreground",
|
|
977
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
978
|
+
},
|
|
979
|
+
size: {
|
|
980
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
981
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
982
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
983
|
+
icon: "size-9",
|
|
984
|
+
"icon-sm": "size-8",
|
|
985
|
+
"icon-lg": "size-10"
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
defaultVariants: {
|
|
989
|
+
variant: "default",
|
|
990
|
+
size: "default"
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
);
|
|
994
|
+
function Button({
|
|
995
|
+
className,
|
|
996
|
+
variant,
|
|
997
|
+
size,
|
|
998
|
+
asChild = false,
|
|
999
|
+
...props
|
|
1000
|
+
}) {
|
|
1001
|
+
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
1002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1003
|
+
Comp,
|
|
1004
|
+
{
|
|
1005
|
+
"data-slot": "button",
|
|
1006
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
1007
|
+
...props
|
|
1008
|
+
}
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/components/controller-primary-action.tsx
|
|
1013
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1014
|
+
var ControllerPrimaryAction = ({
|
|
1015
|
+
label,
|
|
1016
|
+
helper,
|
|
1017
|
+
icon,
|
|
1018
|
+
disabled,
|
|
1019
|
+
onPress,
|
|
1020
|
+
testId,
|
|
1021
|
+
className,
|
|
1022
|
+
buttonClassName
|
|
1023
|
+
}) => {
|
|
1024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: cn("mt-auto pt-3", className), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1025
|
+
Button,
|
|
1026
|
+
{
|
|
1027
|
+
type: "button",
|
|
1028
|
+
onClick: onPress,
|
|
1029
|
+
disabled,
|
|
1030
|
+
"data-testid": testId,
|
|
1031
|
+
"aria-label": label,
|
|
1032
|
+
title: label,
|
|
1033
|
+
className: cn(
|
|
1034
|
+
"flex h-auto min-h-18 w-full items-center justify-between rounded-[1.5rem] border border-white/15 px-5 py-4 text-left shadow-lg",
|
|
1035
|
+
buttonClassName
|
|
1036
|
+
),
|
|
1037
|
+
children: [
|
|
1038
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "min-w-0", children: [
|
|
1039
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate text-base font-black tracking-[0.12em] uppercase sm:text-lg", children: label }),
|
|
1040
|
+
helper ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-1 text-sm/5 font-medium tracking-normal normal-case opacity-80", children: helper }) : null
|
|
1041
|
+
] }),
|
|
1042
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "ml-4 flex shrink-0 items-center justify-center", children: icon }) : null
|
|
1043
|
+
]
|
|
1044
|
+
}
|
|
1045
|
+
) });
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// src/components/host-mute-button.tsx
|
|
1049
|
+
var import_lucide_react = require("lucide-react");
|
|
1050
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1051
|
+
function HostMuteButton({
|
|
1052
|
+
muted,
|
|
1053
|
+
onToggle,
|
|
1054
|
+
className,
|
|
1055
|
+
labelClassName,
|
|
1056
|
+
mutedLabel = "Unmute",
|
|
1057
|
+
unmutedLabel = "Mute"
|
|
1058
|
+
}) {
|
|
1059
|
+
const label = muted ? mutedLabel : unmutedLabel;
|
|
1060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1061
|
+
Button,
|
|
1062
|
+
{
|
|
1063
|
+
type: "button",
|
|
1064
|
+
variant: "ghost",
|
|
1065
|
+
size: "sm",
|
|
1066
|
+
onClick: onToggle,
|
|
1067
|
+
"aria-pressed": muted,
|
|
1068
|
+
"aria-label": label,
|
|
1069
|
+
title: label,
|
|
1070
|
+
className: cn(
|
|
1071
|
+
"rounded-full border border-white/25 bg-black/35 px-3 text-white backdrop-blur-sm hover:bg-black/55",
|
|
1072
|
+
className
|
|
1073
|
+
),
|
|
1074
|
+
children: [
|
|
1075
|
+
muted ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.VolumeX, { className: "size-4" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react.Volume2, { className: "size-4" }),
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1077
|
+
"span",
|
|
1078
|
+
{
|
|
1079
|
+
className: cn(
|
|
1080
|
+
"text-[11px] font-semibold tracking-[0.16em] uppercase",
|
|
1081
|
+
labelClassName
|
|
1082
|
+
),
|
|
1083
|
+
children: label
|
|
1084
|
+
}
|
|
1085
|
+
)
|
|
1086
|
+
]
|
|
1087
|
+
}
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// src/components/join-qr-overlay.tsx
|
|
1092
|
+
var import_react7 = require("react");
|
|
1093
|
+
|
|
1094
|
+
// src/components/room-qr-code.tsx
|
|
1095
|
+
var import_qrcode = require("qrcode");
|
|
1096
|
+
var import_react6 = require("react");
|
|
1097
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1098
|
+
var RoomQrCode = ({
|
|
1099
|
+
value,
|
|
1100
|
+
size = 180,
|
|
1101
|
+
padding = 1,
|
|
1102
|
+
foregroundColor = "#111111",
|
|
1103
|
+
backgroundColor = "#ffffff",
|
|
1104
|
+
errorCorrectionLevel = "M",
|
|
1105
|
+
className = "",
|
|
1106
|
+
style,
|
|
1107
|
+
alt = "Room join QR code"
|
|
1108
|
+
}) => {
|
|
1109
|
+
const trimmed = value.trim();
|
|
1110
|
+
const qrKey = `${trimmed}\0${size}\0${padding}\0${foregroundColor}\0${backgroundColor}\0${errorCorrectionLevel}`;
|
|
1111
|
+
const [qrState, setQrState] = (0, import_react6.useState)({
|
|
1112
|
+
key: null,
|
|
1113
|
+
dataUrl: null,
|
|
1114
|
+
error: false
|
|
1115
|
+
});
|
|
1116
|
+
(0, import_react6.useEffect)(() => {
|
|
1117
|
+
if (!trimmed) {
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
let cancelled = false;
|
|
1121
|
+
void (0, import_qrcode.toDataURL)(trimmed, {
|
|
1122
|
+
width: size,
|
|
1123
|
+
margin: padding,
|
|
1124
|
+
errorCorrectionLevel,
|
|
1125
|
+
color: {
|
|
1126
|
+
dark: foregroundColor,
|
|
1127
|
+
light: backgroundColor
|
|
1128
|
+
}
|
|
1129
|
+
}).then((nextUrl) => {
|
|
1130
|
+
if (!cancelled) {
|
|
1131
|
+
setQrState({
|
|
1132
|
+
key: qrKey,
|
|
1133
|
+
dataUrl: nextUrl,
|
|
1134
|
+
error: false
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
}).catch(() => {
|
|
1138
|
+
if (!cancelled) {
|
|
1139
|
+
setQrState({
|
|
1140
|
+
key: qrKey,
|
|
1141
|
+
dataUrl: null,
|
|
1142
|
+
error: true
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1146
|
+
return () => {
|
|
1147
|
+
cancelled = true;
|
|
1148
|
+
};
|
|
1149
|
+
}, [
|
|
1150
|
+
backgroundColor,
|
|
1151
|
+
errorCorrectionLevel,
|
|
1152
|
+
foregroundColor,
|
|
1153
|
+
padding,
|
|
1154
|
+
size,
|
|
1155
|
+
qrKey,
|
|
1156
|
+
trimmed
|
|
1157
|
+
]);
|
|
1158
|
+
const imageSrc = trimmed && qrState.key === qrKey && qrState.dataUrl ? qrState.dataUrl : null;
|
|
1159
|
+
const isLoading = !!trimmed && qrState.key !== qrKey;
|
|
1160
|
+
const isUnavailable = !trimmed || qrState.key === qrKey && qrState.error;
|
|
1161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1162
|
+
"div",
|
|
1163
|
+
{
|
|
1164
|
+
className,
|
|
1165
|
+
style: {
|
|
1166
|
+
width: size,
|
|
1167
|
+
height: size,
|
|
1168
|
+
...style
|
|
1169
|
+
},
|
|
1170
|
+
"aria-live": "polite",
|
|
1171
|
+
"aria-label": alt,
|
|
1172
|
+
children: imageSrc ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1173
|
+
"img",
|
|
1174
|
+
{
|
|
1175
|
+
src: imageSrc,
|
|
1176
|
+
alt,
|
|
1177
|
+
width: size,
|
|
1178
|
+
height: size,
|
|
1179
|
+
className: "h-full w-full rounded-md object-cover"
|
|
1180
|
+
}
|
|
1181
|
+
) : isLoading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex h-full w-full flex-col items-center justify-center gap-2 rounded-md bg-black/15 text-xs text-white/70", children: [
|
|
1182
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "h-5 w-5 animate-spin rounded-full border-2 border-white/20 border-t-white/80" }),
|
|
1183
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Generating QR\u2026" })
|
|
1184
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex h-full w-full items-center justify-center rounded-md bg-black/15 text-xs text-white/70", children: isUnavailable ? "QR unavailable" : "Generating QR\u2026" })
|
|
1185
|
+
}
|
|
1186
|
+
);
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
// src/components/shell-classes.ts
|
|
1190
|
+
var shellHeaderClassName = "border-b border-white/10 bg-black/28 backdrop-blur-sm";
|
|
1191
|
+
var shellLabelClassName = "text-[0.6875rem] font-semibold tracking-[0.22em] text-white/52 uppercase";
|
|
1192
|
+
var shellHelperTextClassName = "text-sm leading-5 text-white/52";
|
|
1193
|
+
var shellFieldClassName = "h-11 min-w-0 w-full rounded-2xl border border-white/10 bg-black/40 px-3.5 text-sm text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] outline-none placeholder:text-white/35";
|
|
1194
|
+
var shellUtilityButtonClassName = "rounded-2xl border-white/12 bg-white/[0.045] text-white/88 shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] hover:bg-white/[0.085] hover:text-white disabled:border-white/8 disabled:bg-white/[0.03] disabled:text-white/35";
|
|
1195
|
+
var shellPanelClassName = "rounded-[0.5rem] border border-white/10 bg-zinc-950/82 text-white shadow-[0_22px_70px_rgba(0,0,0,0.42)] backdrop-blur-md";
|
|
1196
|
+
|
|
1197
|
+
// src/components/join-qr-overlay.tsx
|
|
1198
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1199
|
+
var JoinQrOverlay = ({
|
|
1200
|
+
open,
|
|
1201
|
+
value,
|
|
1202
|
+
roomId,
|
|
1203
|
+
onClose,
|
|
1204
|
+
title = "Scan to join",
|
|
1205
|
+
description = "Scan with your phone to connect as a controller.",
|
|
1206
|
+
className,
|
|
1207
|
+
panelClassName,
|
|
1208
|
+
qrClassName,
|
|
1209
|
+
size = 440
|
|
1210
|
+
}) => {
|
|
1211
|
+
const joinUrlValue = value?.trim() ?? "";
|
|
1212
|
+
const hasJoinUrl = joinUrlValue.length > 0;
|
|
1213
|
+
(0, import_react7.useEffect)(() => {
|
|
1214
|
+
if (!open || typeof window === "undefined") {
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
const handleKeyDown = (event) => {
|
|
1218
|
+
if (event.key === "Escape") {
|
|
1219
|
+
onClose?.();
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1223
|
+
return () => {
|
|
1224
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
1225
|
+
};
|
|
1226
|
+
}, [onClose, open]);
|
|
1227
|
+
if (!open) {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
const handlePanelClick = (event) => {
|
|
1231
|
+
event.stopPropagation();
|
|
1232
|
+
};
|
|
1233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1234
|
+
"div",
|
|
1235
|
+
{
|
|
1236
|
+
role: "dialog",
|
|
1237
|
+
"aria-modal": "true",
|
|
1238
|
+
"aria-label": roomId ? `Join room ${roomId}` : title,
|
|
1239
|
+
className: cn(
|
|
1240
|
+
"absolute inset-0 z-50 flex items-center justify-center bg-black/82 px-6 py-8 backdrop-blur-md",
|
|
1241
|
+
className
|
|
1242
|
+
),
|
|
1243
|
+
onClick: onClose,
|
|
1244
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1245
|
+
"div",
|
|
1246
|
+
{
|
|
1247
|
+
className: cn(
|
|
1248
|
+
"flex w-full max-w-xl flex-col items-center gap-6 px-6 py-7 text-center",
|
|
1249
|
+
shellPanelClassName,
|
|
1250
|
+
panelClassName
|
|
1251
|
+
),
|
|
1252
|
+
onClick: handlePanelClick,
|
|
1253
|
+
children: [
|
|
1254
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1", children: [
|
|
1255
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-[0.6875rem] font-semibold tracking-[0.22em] text-white/52 uppercase", children: title }),
|
|
1256
|
+
roomId ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-3xl font-semibold tracking-[0.12em] text-white uppercase tabular-nums", children: roomId }) : null
|
|
1257
|
+
] }),
|
|
1258
|
+
hasJoinUrl ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1259
|
+
RoomQrCode,
|
|
1260
|
+
{
|
|
1261
|
+
value: joinUrlValue,
|
|
1262
|
+
size,
|
|
1263
|
+
padding: 2,
|
|
1264
|
+
foregroundColor: "#111827",
|
|
1265
|
+
backgroundColor: "#ffffff",
|
|
1266
|
+
className: cn("rounded-xl bg-white shadow-sm", qrClassName),
|
|
1267
|
+
style: {
|
|
1268
|
+
width: "min(72vw, 26rem)",
|
|
1269
|
+
height: "auto",
|
|
1270
|
+
aspectRatio: "1 / 1"
|
|
1271
|
+
},
|
|
1272
|
+
alt: roomId ? `QR code to join room ${roomId}` : "QR code to join as a controller"
|
|
1273
|
+
}
|
|
1274
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex w-full max-w-[26rem] items-center justify-center rounded-xl border border-white/12 bg-white/6 px-5 py-10 text-sm leading-6 text-white/68", children: "Join URL unavailable right now." }),
|
|
1275
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "max-w-md text-sm leading-6 text-white/68", children: description }),
|
|
1276
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1277
|
+
Button,
|
|
1278
|
+
{
|
|
1279
|
+
type: "button",
|
|
1280
|
+
variant: "outline",
|
|
1281
|
+
onClick: onClose,
|
|
1282
|
+
className: cn("rounded-2xl px-5", shellUtilityButtonClassName),
|
|
1283
|
+
children: "Close"
|
|
1284
|
+
}
|
|
1285
|
+
)
|
|
1286
|
+
]
|
|
1287
|
+
}
|
|
1288
|
+
)
|
|
1289
|
+
}
|
|
1290
|
+
);
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1293
|
+
// src/components/join-url-action-buttons.tsx
|
|
1294
|
+
var import_lucide_react2 = require("lucide-react");
|
|
1295
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1296
|
+
var JoinUrlActionButtons = ({
|
|
1297
|
+
hasValue,
|
|
1298
|
+
copied = false,
|
|
1299
|
+
onCopy,
|
|
1300
|
+
onOpen,
|
|
1301
|
+
qrVisible = false,
|
|
1302
|
+
onToggleQr,
|
|
1303
|
+
className,
|
|
1304
|
+
buttonClassName
|
|
1305
|
+
}) => {
|
|
1306
|
+
const showsQrButton = typeof onToggleQr === "function";
|
|
1307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1308
|
+
"div",
|
|
1309
|
+
{
|
|
1310
|
+
className: cn(
|
|
1311
|
+
"grid w-full gap-2",
|
|
1312
|
+
showsQrButton ? "grid-cols-3" : "grid-cols-2",
|
|
1313
|
+
className
|
|
1314
|
+
),
|
|
1315
|
+
children: [
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1317
|
+
Button,
|
|
1318
|
+
{
|
|
1319
|
+
type: "button",
|
|
1320
|
+
variant: "outline",
|
|
1321
|
+
disabled: !hasValue || !onCopy,
|
|
1322
|
+
onClick: onCopy,
|
|
1323
|
+
"aria-label": copied ? "Copied join link" : "Copy join link",
|
|
1324
|
+
title: copied ? "Copied" : "Copy join link",
|
|
1325
|
+
className: cn(
|
|
1326
|
+
"h-11 min-w-0 justify-center rounded-2xl px-3 text-sm",
|
|
1327
|
+
shellUtilityButtonClassName,
|
|
1328
|
+
buttonClassName
|
|
1329
|
+
),
|
|
1330
|
+
children: [
|
|
1331
|
+
copied ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react2.Check, { className: "h-4 w-4", "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react2.Copy, { className: "h-4 w-4", "aria-hidden": true }),
|
|
1332
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "truncate", children: copied ? "Copied" : "Copy" })
|
|
1333
|
+
]
|
|
1334
|
+
}
|
|
1335
|
+
),
|
|
1336
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1337
|
+
Button,
|
|
1338
|
+
{
|
|
1339
|
+
type: "button",
|
|
1340
|
+
variant: "outline",
|
|
1341
|
+
disabled: !hasValue || !onOpen,
|
|
1342
|
+
onClick: onOpen,
|
|
1343
|
+
"aria-label": "Open join link",
|
|
1344
|
+
title: "Open join link",
|
|
1345
|
+
className: cn(
|
|
1346
|
+
"h-11 min-w-0 justify-center rounded-2xl px-3 text-sm",
|
|
1347
|
+
shellUtilityButtonClassName,
|
|
1348
|
+
buttonClassName
|
|
1349
|
+
),
|
|
1350
|
+
children: [
|
|
1351
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react2.ExternalLink, { className: "h-4 w-4", "aria-hidden": true }),
|
|
1352
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "truncate", children: "New tab" })
|
|
1353
|
+
]
|
|
1354
|
+
}
|
|
1355
|
+
),
|
|
1356
|
+
showsQrButton ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1357
|
+
Button,
|
|
1358
|
+
{
|
|
1359
|
+
type: "button",
|
|
1360
|
+
variant: "outline",
|
|
1361
|
+
disabled: !hasValue,
|
|
1362
|
+
"aria-pressed": qrVisible,
|
|
1363
|
+
onClick: onToggleQr,
|
|
1364
|
+
"aria-label": qrVisible ? "Hide join QR" : "Show join QR",
|
|
1365
|
+
title: qrVisible ? "Hide join QR" : "Show join QR",
|
|
1366
|
+
className: cn(
|
|
1367
|
+
"h-11 min-w-0 justify-center rounded-2xl px-3 text-sm",
|
|
1368
|
+
shellUtilityButtonClassName,
|
|
1369
|
+
buttonClassName
|
|
1370
|
+
),
|
|
1371
|
+
children: [
|
|
1372
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react2.QrCode, { className: "h-4 w-4", "aria-hidden": true }),
|
|
1373
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "truncate", children: qrVisible ? "Hide QR" : "QR code" })
|
|
1374
|
+
]
|
|
1375
|
+
}
|
|
1376
|
+
) : null
|
|
1377
|
+
]
|
|
1378
|
+
}
|
|
1379
|
+
);
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
// src/components/join-url-field.tsx
|
|
1383
|
+
var import_react8 = require("react");
|
|
1384
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1385
|
+
var JoinUrlField = ({
|
|
1386
|
+
value,
|
|
1387
|
+
label = "Controller link",
|
|
1388
|
+
helperText,
|
|
1389
|
+
className,
|
|
1390
|
+
inputClassName,
|
|
1391
|
+
inputId,
|
|
1392
|
+
inputName = "airjam-controller-link"
|
|
1393
|
+
}) => {
|
|
1394
|
+
const hasValue = Boolean(value && value.trim().length > 0);
|
|
1395
|
+
const generatedInputId = (0, import_react8.useId)();
|
|
1396
|
+
const resolvedInputId = inputId ?? generatedInputId;
|
|
1397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: cn("space-y-2.5", className), children: [
|
|
1398
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { className: shellLabelClassName, htmlFor: resolvedInputId, children: label }),
|
|
1399
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1400
|
+
"input",
|
|
1401
|
+
{
|
|
1402
|
+
id: resolvedInputId,
|
|
1403
|
+
name: inputName,
|
|
1404
|
+
type: "text",
|
|
1405
|
+
readOnly: true,
|
|
1406
|
+
value: value ?? "",
|
|
1407
|
+
placeholder: hasValue ? void 0 : "Generating join link...",
|
|
1408
|
+
"aria-label": typeof label === "string" ? label : "Controller join link",
|
|
1409
|
+
className: cn(shellFieldClassName, inputClassName)
|
|
1410
|
+
}
|
|
1411
|
+
),
|
|
1412
|
+
helperText ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: shellHelperTextClassName, children: helperText }) : null
|
|
1413
|
+
] });
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
// src/components/join-url-controls.tsx
|
|
1417
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1418
|
+
var JoinUrlControls = ({
|
|
1419
|
+
value,
|
|
1420
|
+
label = "Controller link",
|
|
1421
|
+
helperText,
|
|
1422
|
+
copied = false,
|
|
1423
|
+
onCopy,
|
|
1424
|
+
onOpen,
|
|
1425
|
+
qrVisible = false,
|
|
1426
|
+
onToggleQr,
|
|
1427
|
+
className,
|
|
1428
|
+
inputClassName,
|
|
1429
|
+
buttonClassName
|
|
1430
|
+
}) => {
|
|
1431
|
+
const hasValue = Boolean(value && value.trim().length > 0);
|
|
1432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: cn("w-full space-y-3", className), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
1433
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1434
|
+
JoinUrlField,
|
|
1435
|
+
{
|
|
1436
|
+
value,
|
|
1437
|
+
label,
|
|
1438
|
+
helperText,
|
|
1439
|
+
className: "w-full min-w-0",
|
|
1440
|
+
inputClassName
|
|
1441
|
+
}
|
|
1442
|
+
),
|
|
1443
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1444
|
+
JoinUrlActionButtons,
|
|
1445
|
+
{
|
|
1446
|
+
hasValue,
|
|
1447
|
+
copied,
|
|
1448
|
+
onCopy,
|
|
1449
|
+
onOpen,
|
|
1450
|
+
qrVisible,
|
|
1451
|
+
onToggleQr,
|
|
1452
|
+
className: "w-full",
|
|
1453
|
+
buttonClassName
|
|
1454
|
+
}
|
|
1455
|
+
)
|
|
1456
|
+
] }) });
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
// src/components/lifecycle-action-group.tsx
|
|
1460
|
+
var import_lucide_react3 = require("lucide-react");
|
|
1461
|
+
|
|
1462
|
+
// src/hooks/use-lifecycle-action-group-model.ts
|
|
1463
|
+
var useLifecycleActionGroupModel = ({
|
|
1464
|
+
phase,
|
|
1465
|
+
runtimeState,
|
|
1466
|
+
canInteract = true,
|
|
1467
|
+
onStart,
|
|
1468
|
+
onTogglePause,
|
|
1469
|
+
onBackToLobby,
|
|
1470
|
+
onRestart,
|
|
1471
|
+
startLabel = "Start",
|
|
1472
|
+
restartLabel = "Restart",
|
|
1473
|
+
backLabel = "Back to Lobby",
|
|
1474
|
+
pauseLabel = "Pause",
|
|
1475
|
+
resumeLabel = "Resume"
|
|
1476
|
+
}) => {
|
|
1477
|
+
const isPaused = runtimeState === "paused";
|
|
1478
|
+
const actions = [];
|
|
1479
|
+
if (phase === "lobby" && onStart) {
|
|
1480
|
+
actions.push({
|
|
1481
|
+
kind: "start",
|
|
1482
|
+
label: startLabel,
|
|
1483
|
+
disabled: !canInteract,
|
|
1484
|
+
tone: "primary",
|
|
1485
|
+
onPress: onStart
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
if (phase === "playing" && onTogglePause) {
|
|
1489
|
+
actions.push({
|
|
1490
|
+
kind: "pause-toggle",
|
|
1491
|
+
label: isPaused ? resumeLabel : pauseLabel,
|
|
1492
|
+
disabled: !canInteract,
|
|
1493
|
+
tone: "secondary",
|
|
1494
|
+
onPress: onTogglePause
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
if (phase === "ended" && (onRestart || onStart)) {
|
|
1498
|
+
actions.push({
|
|
1499
|
+
kind: "restart",
|
|
1500
|
+
label: restartLabel,
|
|
1501
|
+
disabled: !canInteract,
|
|
1502
|
+
tone: "primary",
|
|
1503
|
+
onPress: onRestart ?? onStart
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
if (phase !== "lobby" && onBackToLobby) {
|
|
1507
|
+
actions.push({
|
|
1508
|
+
kind: "back-to-lobby",
|
|
1509
|
+
label: backLabel,
|
|
1510
|
+
disabled: !canInteract,
|
|
1511
|
+
tone: "secondary",
|
|
1512
|
+
onPress: onBackToLobby
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
return { isPaused, actions };
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
// src/components/lifecycle-action-group.tsx
|
|
1519
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1520
|
+
var LifecycleActionGroup = ({
|
|
1521
|
+
phase,
|
|
1522
|
+
runtimeState,
|
|
1523
|
+
canInteract = true,
|
|
1524
|
+
onStart,
|
|
1525
|
+
onTogglePause,
|
|
1526
|
+
onBackToLobby,
|
|
1527
|
+
onRestart,
|
|
1528
|
+
startLabel = "Start",
|
|
1529
|
+
restartLabel = "Restart",
|
|
1530
|
+
backLabel = "Back to Lobby",
|
|
1531
|
+
presentation = "pill",
|
|
1532
|
+
visibleKinds,
|
|
1533
|
+
className,
|
|
1534
|
+
buttonClassName
|
|
1535
|
+
}) => {
|
|
1536
|
+
const { actions: allActions } = useLifecycleActionGroupModel({
|
|
1537
|
+
phase,
|
|
1538
|
+
runtimeState,
|
|
1539
|
+
canInteract,
|
|
1540
|
+
onStart,
|
|
1541
|
+
onTogglePause,
|
|
1542
|
+
onBackToLobby,
|
|
1543
|
+
onRestart,
|
|
1544
|
+
startLabel,
|
|
1545
|
+
restartLabel,
|
|
1546
|
+
backLabel
|
|
1547
|
+
});
|
|
1548
|
+
const actions = visibleKinds ? allActions.filter((action) => visibleKinds.includes(action.kind)) : allActions;
|
|
1549
|
+
if (actions.length === 0) {
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
const renderIcon = (kind, label) => {
|
|
1553
|
+
switch (kind) {
|
|
1554
|
+
case "start":
|
|
1555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.Play, { "aria-hidden": true, className: "size-4.5" });
|
|
1556
|
+
case "pause-toggle":
|
|
1557
|
+
return label.toLowerCase() === "resume" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.Play, { "aria-hidden": true, className: "size-4.5" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.Pause, { "aria-hidden": true, className: "size-4.5" });
|
|
1558
|
+
case "restart":
|
|
1559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.RotateCcw, { "aria-hidden": true, className: "size-4.5" });
|
|
1560
|
+
case "back-to-lobby":
|
|
1561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.House, { "aria-hidden": true, className: "size-4.5" });
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1565
|
+
"div",
|
|
1566
|
+
{
|
|
1567
|
+
className: cn(
|
|
1568
|
+
"flex min-w-0 flex-nowrap items-center justify-end gap-1.5 overflow-x-auto",
|
|
1569
|
+
className
|
|
1570
|
+
),
|
|
1571
|
+
children: actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1572
|
+
Button,
|
|
1573
|
+
{
|
|
1574
|
+
type: "button",
|
|
1575
|
+
variant: presentation === "icon" ? action.tone === "primary" ? "secondary" : "ghost" : action.tone === "primary" ? "default" : "outline",
|
|
1576
|
+
size: presentation === "icon" ? "icon-sm" : void 0,
|
|
1577
|
+
onClick: action.onPress,
|
|
1578
|
+
disabled: action.disabled,
|
|
1579
|
+
"aria-label": action.label,
|
|
1580
|
+
title: action.label,
|
|
1581
|
+
className: cn(
|
|
1582
|
+
presentation === "icon" ? action.tone === "primary" ? "size-9 shrink-0 rounded-full border border-white/20 bg-white text-black hover:bg-white/90 sm:size-10" : "size-9 shrink-0 rounded-full border border-white/12 bg-white/6 text-white hover:bg-white/12 sm:size-10" : action.tone === "primary" ? "h-8 shrink-0 rounded-full border border-white/15 bg-white px-3 py-0 text-[9px] font-semibold tracking-[0.12em] whitespace-nowrap text-black uppercase hover:bg-white/90 sm:h-9 sm:px-4 sm:text-[10px] sm:tracking-[0.16em]" : "h-8 shrink-0 rounded-full border-white/15 bg-white/5 px-3 py-0 text-[9px] font-semibold tracking-[0.12em] whitespace-nowrap text-white uppercase hover:bg-white/10 sm:h-9 sm:px-4 sm:text-[10px] sm:tracking-[0.16em]",
|
|
1583
|
+
buttonClassName
|
|
1584
|
+
),
|
|
1585
|
+
children: presentation === "icon" ? renderIcon(action.kind, action.label) : action.label
|
|
1586
|
+
},
|
|
1587
|
+
action.kind
|
|
1588
|
+
))
|
|
1589
|
+
}
|
|
1590
|
+
);
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
// src/components/player-avatar.tsx
|
|
1594
|
+
var import_lucide_react4 = require("lucide-react");
|
|
1595
|
+
|
|
1596
|
+
// src/utils/player-avatar-url.ts
|
|
1597
|
+
var DIEBEAR_ADVENTURER_NEUTRAL_SVG_BASE = "https://api.dicebear.com/9.x/adventurer-neutral/svg";
|
|
1598
|
+
var AIRJAM_DEFAULT_AVATAR_SEEDS = [
|
|
1599
|
+
"Aiko",
|
|
1600
|
+
"Brayden",
|
|
1601
|
+
"Caleb",
|
|
1602
|
+
"Dylan",
|
|
1603
|
+
"Emery",
|
|
1604
|
+
"Finley",
|
|
1605
|
+
"Grayson",
|
|
1606
|
+
"Harper"
|
|
1607
|
+
];
|
|
1608
|
+
var resolvePlayerAvatarSeed = (player) => {
|
|
1609
|
+
const raw = player.avatarId?.trim();
|
|
1610
|
+
if (!raw) {
|
|
1611
|
+
return player.id;
|
|
1612
|
+
}
|
|
1613
|
+
const match = /^aj-(\d+)$/.exec(raw);
|
|
1614
|
+
if (match) {
|
|
1615
|
+
const index = Number(match[1]) - 1;
|
|
1616
|
+
if (index >= 0 && index < AIRJAM_DEFAULT_AVATAR_SEEDS.length) {
|
|
1617
|
+
return AIRJAM_DEFAULT_AVATAR_SEEDS[index];
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
return raw;
|
|
1621
|
+
};
|
|
1622
|
+
var getDiceBearAdventurerNeutralUrl = (seed) => `${DIEBEAR_ADVENTURER_NEUTRAL_SVG_BASE}?seed=${encodeURIComponent(seed)}`;
|
|
1623
|
+
var getPlayerAvatarImageUrl = (player) => getDiceBearAdventurerNeutralUrl(resolvePlayerAvatarSeed(player));
|
|
1624
|
+
|
|
1625
|
+
// src/components/player-avatar.tsx
|
|
1626
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1627
|
+
var hexToRgba = (hex, opacity) => {
|
|
1628
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
1629
|
+
if (!result) return `rgba(0, 0, 0, ${opacity})`;
|
|
1630
|
+
const r = parseInt(result[1], 16);
|
|
1631
|
+
const g = parseInt(result[2], 16);
|
|
1632
|
+
const b = parseInt(result[3], 16);
|
|
1633
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
1634
|
+
};
|
|
1635
|
+
var PlayerAvatar = ({
|
|
1636
|
+
player,
|
|
1637
|
+
isBot = false,
|
|
1638
|
+
size = "md",
|
|
1639
|
+
className = ""
|
|
1640
|
+
}) => {
|
|
1641
|
+
const accentColor = player.color || "hsl(var(--border))";
|
|
1642
|
+
const sizeClasses = {
|
|
1643
|
+
sm: "h-9 w-9 border-2",
|
|
1644
|
+
md: "h-12 w-12 border-4",
|
|
1645
|
+
lg: "h-16 w-16 border-4"
|
|
1646
|
+
};
|
|
1647
|
+
const shadowStyles = {
|
|
1648
|
+
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)",
|
|
1649
|
+
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)",
|
|
1650
|
+
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)"
|
|
1651
|
+
};
|
|
1652
|
+
const iconSizeClasses = {
|
|
1653
|
+
sm: "h-4 w-4",
|
|
1654
|
+
md: "h-5 w-5",
|
|
1655
|
+
lg: "h-6 w-6"
|
|
1656
|
+
};
|
|
1657
|
+
const shellClassName = cn(
|
|
1658
|
+
"shrink-0 rounded-full shadow-lg",
|
|
1659
|
+
sizeClasses[size],
|
|
1660
|
+
className
|
|
1661
|
+
);
|
|
1662
|
+
if (isBot) {
|
|
1663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1664
|
+
"div",
|
|
1665
|
+
{
|
|
1666
|
+
role: "img",
|
|
1667
|
+
"aria-label": player.label,
|
|
1668
|
+
className: cn(
|
|
1669
|
+
"bg-secondary/40 flex items-center justify-center",
|
|
1670
|
+
shellClassName
|
|
1671
|
+
),
|
|
1672
|
+
style: {
|
|
1673
|
+
borderColor: accentColor,
|
|
1674
|
+
color: accentColor,
|
|
1675
|
+
boxShadow: shadowStyles[size]
|
|
1676
|
+
},
|
|
1677
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.Bot, { "aria-hidden": "true", className: iconSizeClasses[size] })
|
|
1678
|
+
}
|
|
1679
|
+
);
|
|
1680
|
+
}
|
|
1681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1682
|
+
"img",
|
|
1683
|
+
{
|
|
1684
|
+
src: getPlayerAvatarImageUrl(player),
|
|
1685
|
+
alt: player.label,
|
|
1686
|
+
className: cn("bg-secondary/30", shellClassName),
|
|
1687
|
+
style: {
|
|
1688
|
+
borderColor: accentColor,
|
|
1689
|
+
boxShadow: shadowStyles[size]
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
);
|
|
1693
|
+
};
|
|
1694
|
+
|
|
1695
|
+
// src/components/player-avatar-strip.tsx
|
|
1696
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1697
|
+
var overflowSizeClasses = {
|
|
1698
|
+
sm: "h-9 w-9 min-h-9 min-w-9 text-[0.625rem]",
|
|
1699
|
+
md: "h-12 w-12 min-h-12 min-w-12 text-[11px]",
|
|
1700
|
+
lg: "h-16 w-16 min-h-16 min-w-16 text-xs"
|
|
1701
|
+
};
|
|
1702
|
+
var PlayerAvatarStrip = ({
|
|
1703
|
+
players,
|
|
1704
|
+
maxVisible = 4,
|
|
1705
|
+
size = "sm",
|
|
1706
|
+
className,
|
|
1707
|
+
avatarClassName = "",
|
|
1708
|
+
overflowBadgeClassName = ""
|
|
1709
|
+
}) => {
|
|
1710
|
+
const visible = players.slice(0, maxVisible);
|
|
1711
|
+
const overflow = Math.max(0, players.length - maxVisible);
|
|
1712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: cn("flex items-center -space-x-2", className), children: [
|
|
1713
|
+
visible.map((player) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1714
|
+
PlayerAvatar,
|
|
1715
|
+
{
|
|
1716
|
+
player,
|
|
1717
|
+
size,
|
|
1718
|
+
className: avatarClassName
|
|
1719
|
+
},
|
|
1720
|
+
player.id
|
|
1721
|
+
)),
|
|
1722
|
+
overflow > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1723
|
+
"div",
|
|
1724
|
+
{
|
|
1725
|
+
className: cn(
|
|
1726
|
+
"bg-secondary/50 text-foreground flex shrink-0 items-center justify-center rounded-full border-2 border-[hsl(var(--border))] font-semibold tabular-nums shadow-sm",
|
|
1727
|
+
overflowSizeClasses[size],
|
|
1728
|
+
overflowBadgeClassName
|
|
1729
|
+
),
|
|
1730
|
+
"aria-label": `${overflow} more players`,
|
|
1731
|
+
children: [
|
|
1732
|
+
"+",
|
|
1733
|
+
overflow
|
|
1734
|
+
]
|
|
1735
|
+
}
|
|
1736
|
+
)
|
|
1737
|
+
] });
|
|
1738
|
+
};
|
|
1739
|
+
|
|
1740
|
+
// src/components/runtime-shell-header.tsx
|
|
1741
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1742
|
+
var RuntimeShellHeader = ({
|
|
1743
|
+
connectionStatus,
|
|
1744
|
+
leftSlot,
|
|
1745
|
+
rightSlot,
|
|
1746
|
+
className
|
|
1747
|
+
}) => {
|
|
1748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1749
|
+
"header",
|
|
1750
|
+
{
|
|
1751
|
+
className: cn(
|
|
1752
|
+
"flex min-h-16 items-center gap-2.5 px-3 py-2.5 sm:px-4",
|
|
1753
|
+
shellHeaderClassName,
|
|
1754
|
+
className
|
|
1755
|
+
),
|
|
1756
|
+
children: [
|
|
1757
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "min-w-0 flex-1", children: leftSlot }),
|
|
1758
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex shrink-0 items-center gap-2.5", children: [
|
|
1759
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ConnectionStatusPill, { status: connectionStatus }),
|
|
1760
|
+
rightSlot ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex items-center justify-end", children: rightSlot }) : null
|
|
1761
|
+
] })
|
|
1762
|
+
]
|
|
1763
|
+
}
|
|
1764
|
+
);
|
|
1765
|
+
};
|
|
1766
|
+
|
|
1767
|
+
// src/components/surface-viewport.tsx
|
|
1768
|
+
var import_react9 = require("react");
|
|
1769
|
+
|
|
1770
|
+
// src/runtime/controller-bridge.ts
|
|
1771
|
+
var import_zod11 = require("zod");
|
|
1772
|
+
|
|
1773
|
+
// src/contracts/v2/bridge.ts
|
|
1774
|
+
var import_zod7 = require("zod");
|
|
1775
|
+
var roomCodeSchema2 = import_zod7.z.string().trim().min(4).max(8).regex(/^[A-Z0-9]+$/, {
|
|
1776
|
+
message: "room code must contain only A-Z or 0-9"
|
|
1777
|
+
});
|
|
1778
|
+
var runtimeStateSchema = import_zod7.z.enum(["paused", "playing"]);
|
|
1779
|
+
var playerProfileSchema = import_zod7.z.object({
|
|
1780
|
+
id: import_zod7.z.string().min(1),
|
|
1781
|
+
label: import_zod7.z.string().min(1),
|
|
1782
|
+
color: import_zod7.z.string().optional(),
|
|
1783
|
+
avatarId: import_zod7.z.string().optional()
|
|
1784
|
+
}).strict();
|
|
1785
|
+
var inputFrameEntrySchema = import_zod7.z.object({
|
|
1786
|
+
controllerId: import_zod7.z.string().min(1),
|
|
1787
|
+
input: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown())
|
|
1788
|
+
}).strict();
|
|
1789
|
+
var V2_BRIDGE_PARENT_TO_GAME_TYPES = [
|
|
1790
|
+
"BOOTSTRAP",
|
|
1791
|
+
"PLAYERS_UPDATE",
|
|
1792
|
+
"RUNTIME_STATE_UPDATE",
|
|
1793
|
+
"INPUT_FRAME",
|
|
1794
|
+
"PAUSE",
|
|
1795
|
+
"RESUME",
|
|
1796
|
+
"SHUTDOWN"
|
|
1797
|
+
];
|
|
1798
|
+
var V2_BRIDGE_GAME_TO_PARENT_TYPES = [
|
|
1799
|
+
"READY",
|
|
1800
|
+
"STATE_PATCH",
|
|
1801
|
+
"SIGNAL",
|
|
1802
|
+
"ERROR",
|
|
1803
|
+
"METRICS"
|
|
1804
|
+
];
|
|
1805
|
+
var allMessageTypes = [
|
|
1806
|
+
...V2_BRIDGE_PARENT_TO_GAME_TYPES,
|
|
1807
|
+
...V2_BRIDGE_GAME_TO_PARENT_TYPES
|
|
1808
|
+
];
|
|
1809
|
+
var knownBridgeMessageTypeSet = new Set(allMessageTypes);
|
|
1810
|
+
var bootstrapMessageSchema = import_zod7.z.object({
|
|
1811
|
+
type: import_zod7.z.literal("BOOTSTRAP"),
|
|
1812
|
+
payload: import_zod7.z.object({
|
|
1813
|
+
roomId: roomCodeSchema2,
|
|
1814
|
+
players: import_zod7.z.array(playerProfileSchema),
|
|
1815
|
+
state: import_zod7.z.object({
|
|
1816
|
+
runtimeState: runtimeStateSchema,
|
|
1817
|
+
message: import_zod7.z.string().optional()
|
|
1818
|
+
}).strict(),
|
|
1819
|
+
capabilities: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.boolean()).default({})
|
|
1820
|
+
}).strict()
|
|
1821
|
+
}).strict();
|
|
1822
|
+
var playersUpdateMessageSchema = import_zod7.z.object({
|
|
1823
|
+
type: import_zod7.z.literal("PLAYERS_UPDATE"),
|
|
1824
|
+
payload: import_zod7.z.object({
|
|
1825
|
+
players: import_zod7.z.array(playerProfileSchema)
|
|
1826
|
+
}).strict()
|
|
1827
|
+
}).strict();
|
|
1828
|
+
var runtimeStateUpdateMessageSchema = import_zod7.z.object({
|
|
1829
|
+
type: import_zod7.z.literal("RUNTIME_STATE_UPDATE"),
|
|
1830
|
+
payload: import_zod7.z.object({
|
|
1831
|
+
runtimeState: runtimeStateSchema,
|
|
1832
|
+
message: import_zod7.z.string().optional()
|
|
1833
|
+
}).strict()
|
|
1834
|
+
}).strict();
|
|
1835
|
+
var inputFrameMessageSchema = import_zod7.z.object({
|
|
1836
|
+
type: import_zod7.z.literal("INPUT_FRAME"),
|
|
1837
|
+
payload: import_zod7.z.object({
|
|
1838
|
+
frameId: import_zod7.z.number().int().nonnegative(),
|
|
1839
|
+
inputs: import_zod7.z.array(inputFrameEntrySchema)
|
|
1840
|
+
}).strict()
|
|
1841
|
+
}).strict();
|
|
1842
|
+
var pauseMessageSchema = import_zod7.z.object({
|
|
1843
|
+
type: import_zod7.z.literal("PAUSE"),
|
|
1844
|
+
payload: import_zod7.z.object({
|
|
1845
|
+
reason: import_zod7.z.string().optional()
|
|
1846
|
+
}).strict()
|
|
1847
|
+
}).strict();
|
|
1848
|
+
var resumeMessageSchema = import_zod7.z.object({
|
|
1849
|
+
type: import_zod7.z.literal("RESUME"),
|
|
1850
|
+
payload: import_zod7.z.object({}).strict()
|
|
1851
|
+
}).strict();
|
|
1852
|
+
var shutdownMessageSchema = import_zod7.z.object({
|
|
1853
|
+
type: import_zod7.z.literal("SHUTDOWN"),
|
|
1854
|
+
payload: import_zod7.z.object({
|
|
1855
|
+
reason: import_zod7.z.string().min(1)
|
|
1856
|
+
}).strict()
|
|
1857
|
+
}).strict();
|
|
1858
|
+
var readyMessageSchema = import_zod7.z.object({
|
|
1859
|
+
type: import_zod7.z.literal("READY"),
|
|
1860
|
+
payload: import_zod7.z.object({
|
|
1861
|
+
readyAtMs: import_zod7.z.number().int().nonnegative()
|
|
1862
|
+
}).strict()
|
|
1863
|
+
}).strict();
|
|
1864
|
+
var statePatchMessageSchema = import_zod7.z.object({
|
|
1865
|
+
type: import_zod7.z.literal("STATE_PATCH"),
|
|
1866
|
+
payload: import_zod7.z.object({
|
|
1867
|
+
patch: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown())
|
|
1868
|
+
}).strict()
|
|
1869
|
+
}).strict();
|
|
1870
|
+
var signalMessageSchema = import_zod7.z.object({
|
|
1871
|
+
type: import_zod7.z.literal("SIGNAL"),
|
|
1872
|
+
payload: import_zod7.z.object({
|
|
1873
|
+
signalType: import_zod7.z.string().min(1),
|
|
1874
|
+
targetId: import_zod7.z.string().min(1).optional(),
|
|
1875
|
+
data: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown())
|
|
1876
|
+
}).strict()
|
|
1877
|
+
}).strict();
|
|
1878
|
+
var errorMessageSchema = import_zod7.z.object({
|
|
1879
|
+
type: import_zod7.z.literal("ERROR"),
|
|
1880
|
+
payload: import_zod7.z.object({
|
|
1881
|
+
code: import_zod7.z.string().min(1),
|
|
1882
|
+
message: import_zod7.z.string().min(1),
|
|
1883
|
+
details: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown()).optional()
|
|
1884
|
+
}).strict()
|
|
1885
|
+
}).strict();
|
|
1886
|
+
var metricsMessageSchema = import_zod7.z.object({
|
|
1887
|
+
type: import_zod7.z.literal("METRICS"),
|
|
1888
|
+
payload: import_zod7.z.object({
|
|
1889
|
+
values: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.number())
|
|
1890
|
+
}).strict()
|
|
1891
|
+
}).strict();
|
|
1892
|
+
var v2BridgeParentToGameMessageSchema = import_zod7.z.union([
|
|
1893
|
+
bootstrapMessageSchema,
|
|
1894
|
+
playersUpdateMessageSchema,
|
|
1895
|
+
runtimeStateUpdateMessageSchema,
|
|
1896
|
+
inputFrameMessageSchema,
|
|
1897
|
+
pauseMessageSchema,
|
|
1898
|
+
resumeMessageSchema,
|
|
1899
|
+
shutdownMessageSchema
|
|
1900
|
+
]);
|
|
1901
|
+
var v2BridgeGameToParentMessageSchema = import_zod7.z.union([
|
|
1902
|
+
readyMessageSchema,
|
|
1903
|
+
statePatchMessageSchema,
|
|
1904
|
+
signalMessageSchema,
|
|
1905
|
+
errorMessageSchema,
|
|
1906
|
+
metricsMessageSchema
|
|
1907
|
+
]);
|
|
1908
|
+
var v2BridgeMessageSchema = import_zod7.z.union([
|
|
1909
|
+
v2BridgeParentToGameMessageSchema,
|
|
1910
|
+
v2BridgeGameToParentMessageSchema
|
|
1911
|
+
]);
|
|
1912
|
+
|
|
1913
|
+
// src/contracts/v2/handshake.ts
|
|
1914
|
+
var import_zod8 = require("zod");
|
|
1915
|
+
var AIR_JAM_PROTOCOL_V2 = "2";
|
|
1916
|
+
var semanticVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1917
|
+
var v2ProtocolVersionSchema = import_zod8.z.literal(AIR_JAM_PROTOCOL_V2);
|
|
1918
|
+
var runtimeKindSchema = import_zod8.z.enum([
|
|
1919
|
+
"standalone-host",
|
|
1920
|
+
"standalone-controller",
|
|
1921
|
+
"arcade-runtime",
|
|
1922
|
+
"arcade-game-iframe",
|
|
1923
|
+
"arcade-host-runtime",
|
|
1924
|
+
"arcade-host-iframe",
|
|
1925
|
+
"arcade-controller-runtime",
|
|
1926
|
+
"arcade-controller-iframe"
|
|
1927
|
+
]);
|
|
1928
|
+
var capabilityFlagsSchema = import_zod8.z.record(import_zod8.z.string(), import_zod8.z.boolean());
|
|
1929
|
+
var sdkVersionSchema = import_zod8.z.string().regex(
|
|
1930
|
+
semanticVersionPattern,
|
|
1931
|
+
"sdkVersion must use semantic version format (for example 1.2.3)"
|
|
1932
|
+
);
|
|
1933
|
+
var v2HandshakeSchema = import_zod8.z.object({
|
|
1934
|
+
protocolVersion: v2ProtocolVersionSchema,
|
|
1935
|
+
sdkVersion: sdkVersionSchema,
|
|
1936
|
+
runtimeKind: runtimeKindSchema,
|
|
1937
|
+
capabilityFlags: capabilityFlagsSchema.default({})
|
|
1938
|
+
}).strict();
|
|
1939
|
+
|
|
1940
|
+
// src/runtime/arcade-surface-identity.ts
|
|
1941
|
+
var import_zod9 = require("zod");
|
|
1942
|
+
var arcadeSurfaceRuntimeIdentitySchema = import_zod9.z.object({
|
|
1943
|
+
epoch: import_zod9.z.number().int().nonnegative(),
|
|
1944
|
+
kind: import_zod9.z.enum(["browser", "game"]),
|
|
1945
|
+
gameId: import_zod9.z.string().nullable()
|
|
1946
|
+
}).strict();
|
|
1947
|
+
|
|
1948
|
+
// src/runtime/iframe-bridge.ts
|
|
1949
|
+
var import_zod10 = require("zod");
|
|
1950
|
+
var AIRJAM_BRIDGE_INIT = "AIRJAM_BRIDGE_INIT";
|
|
1951
|
+
var AIRJAM_SETTINGS_SYNC = "AIRJAM_SETTINGS_SYNC";
|
|
1952
|
+
var AIRJAM_SETTINGS_READY = "AIRJAM_SETTINGS_READY";
|
|
1953
|
+
var airJamSettingsSyncSchema = import_zod10.z.object({
|
|
1954
|
+
type: import_zod10.z.literal(AIRJAM_SETTINGS_SYNC),
|
|
1955
|
+
payload: import_zod10.z.object({
|
|
1956
|
+
settings: import_zod10.z.object({
|
|
1957
|
+
audio: import_zod10.z.object({
|
|
1958
|
+
masterVolume: import_zod10.z.number(),
|
|
1959
|
+
musicVolume: import_zod10.z.number(),
|
|
1960
|
+
sfxVolume: import_zod10.z.number()
|
|
1961
|
+
}).strict(),
|
|
1962
|
+
accessibility: import_zod10.z.object({
|
|
1963
|
+
reducedMotion: import_zod10.z.boolean(),
|
|
1964
|
+
highContrast: import_zod10.z.boolean()
|
|
1965
|
+
}).strict(),
|
|
1966
|
+
feedback: import_zod10.z.object({
|
|
1967
|
+
hapticsEnabled: import_zod10.z.boolean()
|
|
1968
|
+
}).strict(),
|
|
1969
|
+
previewControllers: import_zod10.z.object({
|
|
1970
|
+
activeOpacity: import_zod10.z.number()
|
|
1971
|
+
}).strict()
|
|
1972
|
+
}).strict()
|
|
1973
|
+
}).strict()
|
|
1974
|
+
}).strict();
|
|
1975
|
+
var airJamBridgeInitSchema = import_zod10.z.object({
|
|
1976
|
+
type: import_zod10.z.literal(AIRJAM_BRIDGE_INIT),
|
|
1977
|
+
payload: import_zod10.z.object({
|
|
1978
|
+
handshake: v2HandshakeSchema
|
|
1979
|
+
}).strict()
|
|
1980
|
+
}).strict();
|
|
1981
|
+
var airJamSettingsReadySchema = import_zod10.z.object({
|
|
1982
|
+
type: import_zod10.z.literal(AIRJAM_SETTINGS_READY),
|
|
1983
|
+
payload: import_zod10.z.object({
|
|
1984
|
+
ready: import_zod10.z.literal(true)
|
|
1985
|
+
}).strict()
|
|
1986
|
+
}).strict();
|
|
1987
|
+
|
|
1988
|
+
// src/runtime/controller-bridge.ts
|
|
1989
|
+
var AIRJAM_CONTROLLER_BRIDGE_REQUEST = "AIRJAM_CONTROLLER_BRIDGE_REQUEST";
|
|
1990
|
+
var AIRJAM_CONTROLLER_BRIDGE_ATTACH = "AIRJAM_CONTROLLER_BRIDGE_ATTACH";
|
|
1991
|
+
var AIRJAM_CONTROLLER_BRIDGE_EVENT = "AIRJAM_CONTROLLER_BRIDGE_EVENT";
|
|
1992
|
+
var AIRJAM_CONTROLLER_BRIDGE_EMIT = "AIRJAM_CONTROLLER_BRIDGE_EMIT";
|
|
1993
|
+
var AIRJAM_CONTROLLER_BRIDGE_CLOSE = "AIRJAM_CONTROLLER_BRIDGE_CLOSE";
|
|
1994
|
+
var AIRJAM_CONTROLLER_PRESENTATION_SYNC = "AIRJAM_CONTROLLER_PRESENTATION_SYNC";
|
|
1995
|
+
var AIRJAM_CONTROLLER_BRIDGE_RESPONSE = "AIRJAM_CONTROLLER_BRIDGE_RESPONSE";
|
|
1996
|
+
var controllerBridgeClientEvents = [
|
|
1997
|
+
"controller:input",
|
|
1998
|
+
"controller:action_rpc",
|
|
1999
|
+
"controller:state_sync_request",
|
|
2000
|
+
"controller:system",
|
|
2001
|
+
"controller:play_sound",
|
|
2002
|
+
"controller:updatePlayerProfile"
|
|
2003
|
+
];
|
|
2004
|
+
var controllerBridgeServerEvents = [
|
|
2005
|
+
"connect",
|
|
2006
|
+
"disconnect",
|
|
2007
|
+
"server:welcome",
|
|
2008
|
+
"server:controllerJoined",
|
|
2009
|
+
"server:controllerLeft",
|
|
2010
|
+
"server:state",
|
|
2011
|
+
"server:hostLeft",
|
|
2012
|
+
"server:error",
|
|
2013
|
+
"server:signal",
|
|
2014
|
+
"server:playSound",
|
|
2015
|
+
"server:playerUpdated",
|
|
2016
|
+
"airjam:state_sync"
|
|
2017
|
+
];
|
|
2018
|
+
var bridgeRequestSchema = import_zod11.z.object({
|
|
2019
|
+
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_REQUEST),
|
|
2020
|
+
payload: import_zod11.z.object({
|
|
2021
|
+
handshake: v2HandshakeSchema,
|
|
2022
|
+
roomId: import_zod11.z.string().min(1),
|
|
2023
|
+
controllerId: import_zod11.z.string().min(1),
|
|
2024
|
+
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema
|
|
2025
|
+
}).strict()
|
|
2026
|
+
}).strict();
|
|
2027
|
+
var bridgeAttachSchema = import_zod11.z.object({
|
|
2028
|
+
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_ATTACH),
|
|
2029
|
+
payload: import_zod11.z.object({
|
|
2030
|
+
handshake: v2HandshakeSchema,
|
|
2031
|
+
snapshot: import_zod11.z.object({
|
|
2032
|
+
roomId: import_zod11.z.string().min(1),
|
|
2033
|
+
controllerId: import_zod11.z.string().min(1),
|
|
2034
|
+
connected: import_zod11.z.boolean(),
|
|
2035
|
+
socketId: import_zod11.z.string().optional(),
|
|
2036
|
+
player: import_zod11.z.unknown().optional(),
|
|
2037
|
+
players: import_zod11.z.array(import_zod11.z.unknown()).optional(),
|
|
2038
|
+
state: import_zod11.z.unknown().optional(),
|
|
2039
|
+
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema
|
|
2040
|
+
}).strict()
|
|
2041
|
+
}).strict()
|
|
2042
|
+
}).strict();
|
|
2043
|
+
var bridgeEventSchema = import_zod11.z.object({
|
|
2044
|
+
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_EVENT),
|
|
2045
|
+
payload: import_zod11.z.object({
|
|
2046
|
+
event: import_zod11.z.enum(controllerBridgeServerEvents),
|
|
2047
|
+
args: import_zod11.z.array(import_zod11.z.unknown()),
|
|
2048
|
+
requestId: import_zod11.z.string().min(1).optional()
|
|
2049
|
+
}).strict()
|
|
2050
|
+
}).strict();
|
|
2051
|
+
var bridgeEmitSchema = import_zod11.z.object({
|
|
2052
|
+
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_EMIT),
|
|
2053
|
+
payload: import_zod11.z.object({
|
|
2054
|
+
event: import_zod11.z.enum(controllerBridgeClientEvents),
|
|
2055
|
+
args: import_zod11.z.array(import_zod11.z.unknown()),
|
|
2056
|
+
requestId: import_zod11.z.string().min(1).optional()
|
|
2057
|
+
}).strict()
|
|
2058
|
+
}).strict();
|
|
2059
|
+
var bridgeResponseSchema = import_zod11.z.object({
|
|
2060
|
+
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_RESPONSE),
|
|
2061
|
+
payload: import_zod11.z.object({
|
|
2062
|
+
requestId: import_zod11.z.string().min(1),
|
|
2063
|
+
ack: import_zod11.z.unknown()
|
|
2064
|
+
}).strict()
|
|
2065
|
+
}).strict();
|
|
2066
|
+
var bridgeCloseSchema = import_zod11.z.object({
|
|
2067
|
+
type: import_zod11.z.literal(AIRJAM_CONTROLLER_BRIDGE_CLOSE),
|
|
2068
|
+
payload: import_zod11.z.object({
|
|
2069
|
+
reason: import_zod11.z.string().optional()
|
|
2070
|
+
}).strict()
|
|
2071
|
+
}).strict();
|
|
2072
|
+
var presentationSyncSchema = import_zod11.z.object({
|
|
2073
|
+
type: import_zod11.z.literal(AIRJAM_CONTROLLER_PRESENTATION_SYNC),
|
|
2074
|
+
payload: import_zod11.z.object({
|
|
2075
|
+
orientation: controllerOrientationSchema,
|
|
2076
|
+
arcadeSurface: arcadeSurfaceRuntimeIdentitySchema
|
|
2077
|
+
}).strict()
|
|
2078
|
+
}).strict();
|
|
2079
|
+
var createControllerPresentationSyncMessage = (payload) => ({
|
|
2080
|
+
type: AIRJAM_CONTROLLER_PRESENTATION_SYNC,
|
|
2081
|
+
payload
|
|
2082
|
+
});
|
|
2083
|
+
|
|
2084
|
+
// src/runtime/arcade-runtime-url.ts
|
|
2085
|
+
var parseOptionalArcadeSurfaceFromSearchParams = (params) => {
|
|
2086
|
+
const epochStr = params.get("aj_arcade_epoch");
|
|
2087
|
+
const kind = params.get("aj_arcade_kind");
|
|
2088
|
+
if (epochStr === null || kind !== "browser" && kind !== "game") {
|
|
2089
|
+
return void 0;
|
|
2090
|
+
}
|
|
2091
|
+
const epoch = Number(epochStr);
|
|
2092
|
+
if (!Number.isFinite(epoch) || epoch < 0 || !Number.isInteger(epoch)) {
|
|
2093
|
+
return void 0;
|
|
2094
|
+
}
|
|
2095
|
+
const gameIdRaw = params.get("aj_arcade_game_id");
|
|
2096
|
+
const gameId = kind === "browser" ? null : gameIdRaw && gameIdRaw.length > 0 ? gameIdRaw : null;
|
|
2097
|
+
return { epoch, kind, gameId };
|
|
2098
|
+
};
|
|
2099
|
+
|
|
2100
|
+
// src/runtime/runtime-session-params.ts
|
|
2101
|
+
var parseOrigin = (value) => {
|
|
2102
|
+
if (!value) {
|
|
2103
|
+
return null;
|
|
2104
|
+
}
|
|
2105
|
+
try {
|
|
2106
|
+
return new URL(value).origin;
|
|
2107
|
+
} catch {
|
|
2108
|
+
return null;
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
var resolveLegacyEmbeddedTopology = ({
|
|
2112
|
+
surfaceRole,
|
|
2113
|
+
joinUrl
|
|
2114
|
+
}) => {
|
|
2115
|
+
if (typeof window === "undefined") {
|
|
2116
|
+
return null;
|
|
2117
|
+
}
|
|
2118
|
+
const appOrigin = window.location.origin;
|
|
2119
|
+
const joinUrlOrigin = parseOrigin(joinUrl);
|
|
2120
|
+
const referrerOrigin = parseOrigin(document.referrer);
|
|
2121
|
+
const embedParentOrigin = joinUrlOrigin ?? referrerOrigin ?? appOrigin;
|
|
2122
|
+
const publicHost = joinUrlOrigin ?? appOrigin;
|
|
2123
|
+
const secureTransport = appOrigin.startsWith("https://") && publicHost.startsWith("https://") && embedParentOrigin.startsWith("https://");
|
|
2124
|
+
return resolveRuntimeTopology({
|
|
2125
|
+
runtimeMode: "arcade-live",
|
|
2126
|
+
surfaceRole,
|
|
2127
|
+
appOrigin,
|
|
2128
|
+
backendOrigin: appOrigin,
|
|
2129
|
+
socketOrigin: appOrigin,
|
|
2130
|
+
publicHost,
|
|
2131
|
+
assetBasePath: "/",
|
|
2132
|
+
secureTransport,
|
|
2133
|
+
embedded: true,
|
|
2134
|
+
embedParentOrigin,
|
|
2135
|
+
proxyStrategy: "none"
|
|
2136
|
+
});
|
|
2137
|
+
};
|
|
2138
|
+
var readEmbeddedControllerRuntimeParams = () => {
|
|
2139
|
+
if (typeof window === "undefined") {
|
|
2140
|
+
return null;
|
|
2141
|
+
}
|
|
2142
|
+
const params = new URLSearchParams(window.location.search);
|
|
2143
|
+
const room = params.get("aj_room");
|
|
2144
|
+
const controllerId = params.get("aj_controller_id");
|
|
2145
|
+
if (!room || !controllerId) {
|
|
2146
|
+
return null;
|
|
2147
|
+
}
|
|
2148
|
+
const topology = parseRuntimeTopologyFromSearchParams(params) ?? resolveLegacyEmbeddedTopology({
|
|
2149
|
+
surfaceRole: "controller"
|
|
2150
|
+
});
|
|
2151
|
+
if (!topology) {
|
|
2152
|
+
return null;
|
|
2153
|
+
}
|
|
2154
|
+
const arcadeSurface = parseOptionalArcadeSurfaceFromSearchParams(params);
|
|
2155
|
+
if (!arcadeSurface) {
|
|
2156
|
+
return null;
|
|
2157
|
+
}
|
|
2158
|
+
const rawLabel = params.get("aj_player_label")?.trim();
|
|
2159
|
+
const rawAvatarId = params.get("aj_player_avatar")?.trim();
|
|
2160
|
+
const playerProfile = rawLabel || rawAvatarId ? {
|
|
2161
|
+
...rawLabel ? { label: rawLabel } : {},
|
|
2162
|
+
...rawAvatarId ? { avatarId: rawAvatarId } : {}
|
|
2163
|
+
} : void 0;
|
|
2164
|
+
return {
|
|
2165
|
+
room,
|
|
2166
|
+
controllerId,
|
|
2167
|
+
topology,
|
|
2168
|
+
arcadeSurface,
|
|
2169
|
+
...playerProfile ? { playerProfile } : {}
|
|
2170
|
+
};
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
// src/runtime/controller-presentation.ts
|
|
2174
|
+
var publishEmbeddedControllerPresentation = (orientation) => {
|
|
2175
|
+
if (typeof window === "undefined" || window.parent === window) {
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
const runtimeParams = readEmbeddedControllerRuntimeParams();
|
|
2179
|
+
if (!runtimeParams) {
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
window.parent.postMessage(
|
|
2183
|
+
createControllerPresentationSyncMessage({
|
|
2184
|
+
orientation,
|
|
2185
|
+
arcadeSurface: runtimeParams.arcadeSurface
|
|
2186
|
+
}),
|
|
2187
|
+
runtimeParams.topology.embedParentOrigin ?? "*"
|
|
2188
|
+
);
|
|
2189
|
+
};
|
|
2190
|
+
|
|
2191
|
+
// src/components/surface-orientation-layout.ts
|
|
2192
|
+
var AIRJAM_SAFE_AREA_TOP = "env(safe-area-inset-top, 0px)";
|
|
2193
|
+
var AIRJAM_SAFE_AREA_RIGHT = "env(safe-area-inset-right, 0px)";
|
|
2194
|
+
var AIRJAM_SAFE_AREA_BOTTOM = "env(safe-area-inset-bottom, 0px)";
|
|
2195
|
+
var AIRJAM_SAFE_AREA_LEFT = "env(safe-area-inset-left, 0px)";
|
|
2196
|
+
var AIRJAM_SAFE_VIEWPORT_WIDTH = `calc(100dvw - ${AIRJAM_SAFE_AREA_LEFT} - ${AIRJAM_SAFE_AREA_RIGHT})`;
|
|
2197
|
+
var AIRJAM_SAFE_VIEWPORT_HEIGHT = `calc(100dvh - ${AIRJAM_SAFE_AREA_TOP} - ${AIRJAM_SAFE_AREA_BOTTOM})`;
|
|
2198
|
+
var createSurfaceViewportOuterStyle = () => ({
|
|
2199
|
+
["--airjam-safe-area-top"]: AIRJAM_SAFE_AREA_TOP,
|
|
2200
|
+
["--airjam-safe-area-right"]: AIRJAM_SAFE_AREA_RIGHT,
|
|
2201
|
+
["--airjam-safe-area-bottom"]: AIRJAM_SAFE_AREA_BOTTOM,
|
|
2202
|
+
["--airjam-safe-area-left"]: AIRJAM_SAFE_AREA_LEFT,
|
|
2203
|
+
["--airjam-safe-viewport-width"]: AIRJAM_SAFE_VIEWPORT_WIDTH,
|
|
2204
|
+
["--airjam-safe-viewport-height"]: AIRJAM_SAFE_VIEWPORT_HEIGHT
|
|
2205
|
+
});
|
|
2206
|
+
var resolveForcedOrientationFrameStyle = (desired, needsRotation) => {
|
|
2207
|
+
if (!needsRotation) {
|
|
2208
|
+
return {
|
|
2209
|
+
position: "absolute",
|
|
2210
|
+
top: AIRJAM_SAFE_AREA_TOP,
|
|
2211
|
+
left: AIRJAM_SAFE_AREA_LEFT,
|
|
2212
|
+
width: AIRJAM_SAFE_VIEWPORT_WIDTH,
|
|
2213
|
+
height: AIRJAM_SAFE_VIEWPORT_HEIGHT,
|
|
2214
|
+
overflow: "hidden"
|
|
2215
|
+
};
|
|
2216
|
+
}
|
|
2217
|
+
if (desired === "landscape") {
|
|
2218
|
+
return {
|
|
2219
|
+
position: "absolute",
|
|
2220
|
+
top: AIRJAM_SAFE_AREA_TOP,
|
|
2221
|
+
left: AIRJAM_SAFE_AREA_LEFT,
|
|
2222
|
+
width: AIRJAM_SAFE_VIEWPORT_HEIGHT,
|
|
2223
|
+
height: AIRJAM_SAFE_VIEWPORT_WIDTH,
|
|
2224
|
+
overflow: "hidden",
|
|
2225
|
+
transformOrigin: "top left",
|
|
2226
|
+
transform: `translateX(${AIRJAM_SAFE_VIEWPORT_WIDTH}) rotate(90deg)`
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
return {
|
|
2230
|
+
position: "absolute",
|
|
2231
|
+
top: AIRJAM_SAFE_AREA_TOP,
|
|
2232
|
+
left: AIRJAM_SAFE_AREA_LEFT,
|
|
2233
|
+
width: AIRJAM_SAFE_VIEWPORT_HEIGHT,
|
|
2234
|
+
height: AIRJAM_SAFE_VIEWPORT_WIDTH,
|
|
2235
|
+
overflow: "hidden",
|
|
2236
|
+
transformOrigin: "top left",
|
|
2237
|
+
transform: `translateY(${AIRJAM_SAFE_VIEWPORT_HEIGHT}) rotate(-90deg)`
|
|
2238
|
+
};
|
|
2239
|
+
};
|
|
2240
|
+
|
|
2241
|
+
// src/components/surface-viewport-layout.ts
|
|
2242
|
+
var CONTROLLER_REFERENCE_SIZE = {
|
|
2243
|
+
portrait: {
|
|
2244
|
+
width: 412,
|
|
2245
|
+
height: 915
|
|
2246
|
+
},
|
|
2247
|
+
landscape: {
|
|
2248
|
+
width: 915,
|
|
2249
|
+
height: 412
|
|
2250
|
+
}
|
|
2251
|
+
};
|
|
2252
|
+
var HOST_REFERENCE_SIZE = {
|
|
2253
|
+
portrait: {
|
|
2254
|
+
width: 900,
|
|
2255
|
+
height: 1600
|
|
2256
|
+
},
|
|
2257
|
+
landscape: {
|
|
2258
|
+
width: 1600,
|
|
2259
|
+
height: 900
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
var resolveSurfaceViewportScopeReferenceSize = (sessionScope) => {
|
|
2263
|
+
if (sessionScope === "controller") {
|
|
2264
|
+
return CONTROLLER_REFERENCE_SIZE;
|
|
2265
|
+
}
|
|
2266
|
+
if (sessionScope === "host") {
|
|
2267
|
+
return HOST_REFERENCE_SIZE;
|
|
2268
|
+
}
|
|
2269
|
+
return null;
|
|
2270
|
+
};
|
|
2271
|
+
var resolveSurfaceViewportReferenceSize = ({
|
|
2272
|
+
sessionScope,
|
|
2273
|
+
designWidth,
|
|
2274
|
+
designHeight,
|
|
2275
|
+
orientation,
|
|
2276
|
+
availableWidth,
|
|
2277
|
+
availableHeight
|
|
2278
|
+
}) => {
|
|
2279
|
+
if (typeof designWidth === "number" && Number.isFinite(designWidth) && designWidth > 0 && typeof designHeight === "number" && Number.isFinite(designHeight) && designHeight > 0) {
|
|
2280
|
+
return {
|
|
2281
|
+
width: designWidth,
|
|
2282
|
+
height: designHeight
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
const scopedReferenceSize = resolveSurfaceViewportScopeReferenceSize(sessionScope);
|
|
2286
|
+
if (scopedReferenceSize) {
|
|
2287
|
+
return scopedReferenceSize[orientation];
|
|
2288
|
+
}
|
|
2289
|
+
return {
|
|
2290
|
+
width: Math.max(availableWidth, 1),
|
|
2291
|
+
height: Math.max(availableHeight, 1)
|
|
2292
|
+
};
|
|
2293
|
+
};
|
|
2294
|
+
var SURFACE_VIEWPORT_TEXT_SIZE_BASES = {
|
|
2295
|
+
xs: "0.75rem",
|
|
2296
|
+
sm: "0.875rem",
|
|
2297
|
+
base: "1rem",
|
|
2298
|
+
lg: "1.125rem",
|
|
2299
|
+
xl: "1.25rem",
|
|
2300
|
+
"2xl": "1.5rem",
|
|
2301
|
+
"3xl": "1.875rem",
|
|
2302
|
+
"4xl": "2.25rem",
|
|
2303
|
+
"5xl": "3rem",
|
|
2304
|
+
"6xl": "3.75rem",
|
|
2305
|
+
"7xl": "4.5rem",
|
|
2306
|
+
"8xl": "6rem",
|
|
2307
|
+
"9xl": "8rem"
|
|
2308
|
+
};
|
|
2309
|
+
var SURFACE_VIEWPORT_CONTAINER_BASES = {
|
|
2310
|
+
"3xs": "16rem",
|
|
2311
|
+
"2xs": "18rem",
|
|
2312
|
+
xs: "20rem",
|
|
2313
|
+
sm: "24rem",
|
|
2314
|
+
md: "28rem",
|
|
2315
|
+
lg: "32rem",
|
|
2316
|
+
xl: "36rem",
|
|
2317
|
+
"2xl": "42rem",
|
|
2318
|
+
"3xl": "48rem",
|
|
2319
|
+
"4xl": "56rem",
|
|
2320
|
+
"5xl": "64rem",
|
|
2321
|
+
"6xl": "72rem",
|
|
2322
|
+
"7xl": "80rem"
|
|
2323
|
+
};
|
|
2324
|
+
var SURFACE_VIEWPORT_RADIUS_BASES = {
|
|
2325
|
+
xs: "0.125rem",
|
|
2326
|
+
sm: "0.375rem",
|
|
2327
|
+
md: "0.5rem",
|
|
2328
|
+
lg: "0.625rem",
|
|
2329
|
+
xl: "0.875rem",
|
|
2330
|
+
"2xl": "1rem",
|
|
2331
|
+
"3xl": "1.5rem",
|
|
2332
|
+
"4xl": "2rem"
|
|
2333
|
+
};
|
|
2334
|
+
var resolveSurfaceViewportAvailableSize = ({
|
|
2335
|
+
safeViewportWidth,
|
|
2336
|
+
safeViewportHeight,
|
|
2337
|
+
orientation,
|
|
2338
|
+
needsRotation
|
|
2339
|
+
}) => {
|
|
2340
|
+
if (!orientation || !needsRotation) {
|
|
2341
|
+
return {
|
|
2342
|
+
width: safeViewportWidth,
|
|
2343
|
+
height: safeViewportHeight
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
return {
|
|
2347
|
+
width: safeViewportHeight,
|
|
2348
|
+
height: safeViewportWidth
|
|
2349
|
+
};
|
|
2350
|
+
};
|
|
2351
|
+
var resolveSurfaceViewportScale = ({
|
|
2352
|
+
availableWidth,
|
|
2353
|
+
availableHeight,
|
|
2354
|
+
referenceWidth,
|
|
2355
|
+
referenceHeight,
|
|
2356
|
+
scaleMode = "fit",
|
|
2357
|
+
uiScaleMultiplier = 1,
|
|
2358
|
+
minScale,
|
|
2359
|
+
maxScale
|
|
2360
|
+
}) => {
|
|
2361
|
+
const safeAvailableWidth = Math.max(availableWidth, 1);
|
|
2362
|
+
const safeAvailableHeight = Math.max(availableHeight, 1);
|
|
2363
|
+
const safeReferenceWidth = Math.max(referenceWidth, 1);
|
|
2364
|
+
const safeReferenceHeight = Math.max(referenceHeight, 1);
|
|
2365
|
+
const widthScale = safeAvailableWidth / safeReferenceWidth;
|
|
2366
|
+
const heightScale = safeAvailableHeight / safeReferenceHeight;
|
|
2367
|
+
const baseScale = scaleMode === "width" ? widthScale : scaleMode === "height" ? heightScale : Math.min(widthScale, heightScale);
|
|
2368
|
+
let scale = baseScale * uiScaleMultiplier;
|
|
2369
|
+
if (typeof minScale === "number" && Number.isFinite(minScale)) {
|
|
2370
|
+
scale = Math.max(scale, minScale);
|
|
2371
|
+
}
|
|
2372
|
+
if (typeof maxScale === "number" && Number.isFinite(maxScale)) {
|
|
2373
|
+
scale = Math.min(scale, maxScale);
|
|
2374
|
+
}
|
|
2375
|
+
return scale;
|
|
2376
|
+
};
|
|
2377
|
+
var createScaledVariableValue = (baseValue) => `calc(${baseValue} * var(--airjam-ui-scale))`;
|
|
2378
|
+
var createSurfaceViewportScaleStyle = ({
|
|
2379
|
+
scale,
|
|
2380
|
+
referenceWidth,
|
|
2381
|
+
referenceHeight
|
|
2382
|
+
}) => {
|
|
2383
|
+
const style = {
|
|
2384
|
+
position: "relative",
|
|
2385
|
+
width: "100%",
|
|
2386
|
+
height: "100%",
|
|
2387
|
+
overflow: "hidden",
|
|
2388
|
+
fontSize: createScaledVariableValue("1rem"),
|
|
2389
|
+
"--airjam-ui-scale": String(scale),
|
|
2390
|
+
"--airjam-ui-rem": createScaledVariableValue("1rem"),
|
|
2391
|
+
"--airjam-reference-width": `${referenceWidth}px`,
|
|
2392
|
+
"--airjam-reference-height": `${referenceHeight}px`,
|
|
2393
|
+
"--spacing": createScaledVariableValue("0.25rem"),
|
|
2394
|
+
"--radius": createScaledVariableValue("0.625rem")
|
|
2395
|
+
};
|
|
2396
|
+
for (const [name, baseValue] of Object.entries(
|
|
2397
|
+
SURFACE_VIEWPORT_TEXT_SIZE_BASES
|
|
2398
|
+
)) {
|
|
2399
|
+
style[`--text-${name}`] = createScaledVariableValue(baseValue);
|
|
2400
|
+
}
|
|
2401
|
+
for (const [name, baseValue] of Object.entries(
|
|
2402
|
+
SURFACE_VIEWPORT_CONTAINER_BASES
|
|
2403
|
+
)) {
|
|
2404
|
+
style[`--container-${name}`] = createScaledVariableValue(baseValue);
|
|
2405
|
+
}
|
|
2406
|
+
for (const [name, baseValue] of Object.entries(
|
|
2407
|
+
SURFACE_VIEWPORT_RADIUS_BASES
|
|
2408
|
+
)) {
|
|
2409
|
+
style[`--radius-${name}`] = createScaledVariableValue(baseValue);
|
|
2410
|
+
}
|
|
2411
|
+
return style;
|
|
2412
|
+
};
|
|
2413
|
+
|
|
2414
|
+
// src/components/surface-viewport.tsx
|
|
2415
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2416
|
+
var readLayoutViewportSize = () => {
|
|
2417
|
+
if (typeof window === "undefined") {
|
|
2418
|
+
return { width: 0, height: 0 };
|
|
2419
|
+
}
|
|
2420
|
+
return {
|
|
2421
|
+
width: window.innerWidth,
|
|
2422
|
+
height: window.innerHeight
|
|
2423
|
+
};
|
|
2424
|
+
};
|
|
2425
|
+
var isTextEntryElement = (element) => {
|
|
2426
|
+
if (!element) {
|
|
2427
|
+
return false;
|
|
2428
|
+
}
|
|
2429
|
+
if (element instanceof HTMLTextAreaElement) {
|
|
2430
|
+
return true;
|
|
2431
|
+
}
|
|
2432
|
+
if (element instanceof HTMLInputElement) {
|
|
2433
|
+
return ![
|
|
2434
|
+
"button",
|
|
2435
|
+
"checkbox",
|
|
2436
|
+
"color",
|
|
2437
|
+
"file",
|
|
2438
|
+
"hidden",
|
|
2439
|
+
"image",
|
|
2440
|
+
"radio",
|
|
2441
|
+
"range",
|
|
2442
|
+
"reset",
|
|
2443
|
+
"submit"
|
|
2444
|
+
].includes(element.type);
|
|
2445
|
+
}
|
|
2446
|
+
return element instanceof HTMLElement && element.isContentEditable;
|
|
2447
|
+
};
|
|
2448
|
+
var isKeyboardResize = (previous, next) => {
|
|
2449
|
+
if (!previous || typeof document === "undefined") {
|
|
2450
|
+
return false;
|
|
2451
|
+
}
|
|
2452
|
+
if (!isTextEntryElement(document.activeElement)) {
|
|
2453
|
+
return false;
|
|
2454
|
+
}
|
|
2455
|
+
const sameWidth = Math.abs(previous.width - next.width) <= 2;
|
|
2456
|
+
const heightShrank = next.height < previous.height;
|
|
2457
|
+
return sameWidth && heightShrank;
|
|
2458
|
+
};
|
|
2459
|
+
var getOrientation = ({
|
|
2460
|
+
width,
|
|
2461
|
+
height
|
|
2462
|
+
}) => {
|
|
2463
|
+
if (typeof window !== "undefined") {
|
|
2464
|
+
if (window.matchMedia) {
|
|
2465
|
+
if (window.matchMedia("(orientation: portrait)").matches) {
|
|
2466
|
+
return "portrait";
|
|
2467
|
+
}
|
|
2468
|
+
if (window.matchMedia("(orientation: landscape)").matches) {
|
|
2469
|
+
return "landscape";
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
if (window.screen?.orientation?.type) {
|
|
2473
|
+
if (window.screen.orientation.type.startsWith("portrait")) {
|
|
2474
|
+
return "portrait";
|
|
2475
|
+
}
|
|
2476
|
+
if (window.screen.orientation.type.startsWith("landscape")) {
|
|
2477
|
+
return "landscape";
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
if (width > 0 && height > 0) {
|
|
2482
|
+
return width >= height ? "landscape" : "portrait";
|
|
2483
|
+
}
|
|
2484
|
+
return width >= height ? "landscape" : "portrait";
|
|
2485
|
+
};
|
|
2486
|
+
var SurfaceViewport = ({
|
|
2487
|
+
children,
|
|
2488
|
+
orientation,
|
|
2489
|
+
lockOnGesture = true,
|
|
2490
|
+
className,
|
|
2491
|
+
contentClassName,
|
|
2492
|
+
style,
|
|
2493
|
+
designWidth,
|
|
2494
|
+
designHeight,
|
|
2495
|
+
uiScaleMultiplier,
|
|
2496
|
+
minScale,
|
|
2497
|
+
maxScale
|
|
2498
|
+
}) => {
|
|
2499
|
+
const [viewport, setViewport] = (0, import_react9.useState)(null);
|
|
2500
|
+
const viewportRef = (0, import_react9.useRef)(null);
|
|
2501
|
+
const sessionScope = useSessionScope();
|
|
2502
|
+
(0, import_react9.useEffect)(() => {
|
|
2503
|
+
if (typeof window === "undefined") {
|
|
2504
|
+
return;
|
|
2505
|
+
}
|
|
2506
|
+
const updateViewport = () => {
|
|
2507
|
+
const nextViewport = readLayoutViewportSize();
|
|
2508
|
+
if (isKeyboardResize(viewportRef.current, nextViewport)) {
|
|
2509
|
+
return;
|
|
2510
|
+
}
|
|
2511
|
+
viewportRef.current = nextViewport;
|
|
2512
|
+
setViewport(nextViewport);
|
|
2513
|
+
};
|
|
2514
|
+
updateViewport();
|
|
2515
|
+
window.addEventListener("resize", updateViewport);
|
|
2516
|
+
window.visualViewport?.addEventListener("resize", updateViewport);
|
|
2517
|
+
window.addEventListener("orientationchange", updateViewport);
|
|
2518
|
+
return () => {
|
|
2519
|
+
window.removeEventListener("resize", updateViewport);
|
|
2520
|
+
window.visualViewport?.removeEventListener("resize", updateViewport);
|
|
2521
|
+
window.removeEventListener("orientationchange", updateViewport);
|
|
2522
|
+
};
|
|
2523
|
+
}, []);
|
|
2524
|
+
(0, import_react9.useEffect)(() => {
|
|
2525
|
+
if (typeof window === "undefined" || !orientation || !lockOnGesture) {
|
|
2526
|
+
return;
|
|
2527
|
+
}
|
|
2528
|
+
const tryLock = () => {
|
|
2529
|
+
if (!("orientation" in screen)) {
|
|
2530
|
+
return;
|
|
2531
|
+
}
|
|
2532
|
+
const screenOrientation = screen.orientation;
|
|
2533
|
+
if (!screenOrientation?.lock) {
|
|
2534
|
+
return;
|
|
2535
|
+
}
|
|
2536
|
+
void screenOrientation.lock(orientation).catch(() => {
|
|
2537
|
+
});
|
|
2538
|
+
};
|
|
2539
|
+
const onFirstGesture = () => {
|
|
2540
|
+
tryLock();
|
|
2541
|
+
window.removeEventListener("pointerdown", onFirstGesture, true);
|
|
2542
|
+
};
|
|
2543
|
+
window.addEventListener("pointerdown", onFirstGesture, true);
|
|
2544
|
+
return () => {
|
|
2545
|
+
window.removeEventListener("pointerdown", onFirstGesture, true);
|
|
2546
|
+
};
|
|
2547
|
+
}, [orientation, lockOnGesture]);
|
|
2548
|
+
(0, import_react9.useEffect)(() => {
|
|
2549
|
+
if (!orientation || sessionScope !== "controller") {
|
|
2550
|
+
return;
|
|
2551
|
+
}
|
|
2552
|
+
publishEmbeddedControllerPresentation(orientation);
|
|
2553
|
+
}, [orientation, sessionScope]);
|
|
2554
|
+
const currentOrientation = viewport ? getOrientation(viewport) : "portrait";
|
|
2555
|
+
const effectiveOrientation = orientation ?? currentOrientation;
|
|
2556
|
+
const needsRotation = orientation ? currentOrientation !== orientation : false;
|
|
2557
|
+
const shellStyle = (0, import_react9.useMemo)(
|
|
2558
|
+
() => orientation ? resolveForcedOrientationFrameStyle(orientation, needsRotation) : resolveForcedOrientationFrameStyle(effectiveOrientation, false),
|
|
2559
|
+
[effectiveOrientation, needsRotation, orientation]
|
|
2560
|
+
);
|
|
2561
|
+
const availableSize = (0, import_react9.useMemo)(
|
|
2562
|
+
() => resolveSurfaceViewportAvailableSize({
|
|
2563
|
+
safeViewportWidth: viewport?.width ?? 0,
|
|
2564
|
+
safeViewportHeight: viewport?.height ?? 0,
|
|
2565
|
+
orientation,
|
|
2566
|
+
needsRotation
|
|
2567
|
+
}),
|
|
2568
|
+
[needsRotation, orientation, viewport]
|
|
2569
|
+
);
|
|
2570
|
+
const referenceSize = (0, import_react9.useMemo)(
|
|
2571
|
+
() => resolveSurfaceViewportReferenceSize({
|
|
2572
|
+
sessionScope,
|
|
2573
|
+
designWidth,
|
|
2574
|
+
designHeight,
|
|
2575
|
+
orientation: effectiveOrientation,
|
|
2576
|
+
availableWidth: availableSize.width,
|
|
2577
|
+
availableHeight: availableSize.height
|
|
2578
|
+
}),
|
|
2579
|
+
[
|
|
2580
|
+
availableSize.height,
|
|
2581
|
+
availableSize.width,
|
|
2582
|
+
designHeight,
|
|
2583
|
+
designWidth,
|
|
2584
|
+
effectiveOrientation,
|
|
2585
|
+
sessionScope
|
|
2586
|
+
]
|
|
2587
|
+
);
|
|
2588
|
+
const scale = (0, import_react9.useMemo)(() => {
|
|
2589
|
+
const scaleMode = sessionScope === "controller" ? effectiveOrientation === "portrait" ? "width" : "height" : "fit";
|
|
2590
|
+
return resolveSurfaceViewportScale({
|
|
2591
|
+
availableWidth: availableSize.width,
|
|
2592
|
+
availableHeight: availableSize.height,
|
|
2593
|
+
referenceWidth: referenceSize.width,
|
|
2594
|
+
referenceHeight: referenceSize.height,
|
|
2595
|
+
scaleMode,
|
|
2596
|
+
uiScaleMultiplier,
|
|
2597
|
+
minScale,
|
|
2598
|
+
maxScale
|
|
2599
|
+
});
|
|
2600
|
+
}, [
|
|
2601
|
+
availableSize.height,
|
|
2602
|
+
availableSize.width,
|
|
2603
|
+
effectiveOrientation,
|
|
2604
|
+
maxScale,
|
|
2605
|
+
minScale,
|
|
2606
|
+
referenceSize.height,
|
|
2607
|
+
referenceSize.width,
|
|
2608
|
+
sessionScope,
|
|
2609
|
+
uiScaleMultiplier
|
|
2610
|
+
]);
|
|
2611
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2612
|
+
"div",
|
|
2613
|
+
{
|
|
2614
|
+
className: cn("fixed inset-0 overflow-hidden", className),
|
|
2615
|
+
style: {
|
|
2616
|
+
...createSurfaceViewportOuterStyle(),
|
|
2617
|
+
...style
|
|
2618
|
+
},
|
|
2619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: shellStyle, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2620
|
+
"div",
|
|
2621
|
+
{
|
|
2622
|
+
className: cn("h-full w-full overflow-hidden", contentClassName),
|
|
2623
|
+
"data-airjam-surface-viewport": "true",
|
|
2624
|
+
style: createSurfaceViewportScaleStyle({
|
|
2625
|
+
scale,
|
|
2626
|
+
referenceWidth: referenceSize.width,
|
|
2627
|
+
referenceHeight: referenceSize.height
|
|
2628
|
+
}),
|
|
2629
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "h-full w-full", "data-airjam-surface-root": "true", children })
|
|
2630
|
+
}
|
|
2631
|
+
) })
|
|
2632
|
+
}
|
|
2633
|
+
);
|
|
2634
|
+
};
|
|
2635
|
+
|
|
2636
|
+
// src/components/ui/slider.tsx
|
|
2637
|
+
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"), 1);
|
|
2638
|
+
var React = __toESM(require("react"), 1);
|
|
2639
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2640
|
+
function Slider({
|
|
2641
|
+
className,
|
|
2642
|
+
defaultValue,
|
|
2643
|
+
value,
|
|
2644
|
+
min = 0,
|
|
2645
|
+
max = 100,
|
|
2646
|
+
...props
|
|
2647
|
+
}) {
|
|
2648
|
+
const _values = React.useMemo(
|
|
2649
|
+
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
2650
|
+
[value, defaultValue, min, max]
|
|
2651
|
+
);
|
|
2652
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2653
|
+
SliderPrimitive.Root,
|
|
2654
|
+
{
|
|
2655
|
+
"data-slot": "slider",
|
|
2656
|
+
defaultValue,
|
|
2657
|
+
value,
|
|
2658
|
+
min,
|
|
2659
|
+
max,
|
|
2660
|
+
className: cn(
|
|
2661
|
+
"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",
|
|
2662
|
+
className
|
|
2663
|
+
),
|
|
2664
|
+
...props,
|
|
2665
|
+
children: [
|
|
2666
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2667
|
+
SliderPrimitive.Track,
|
|
2668
|
+
{
|
|
2669
|
+
"data-slot": "slider-track",
|
|
2670
|
+
className: cn(
|
|
2671
|
+
"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"
|
|
2672
|
+
),
|
|
2673
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2674
|
+
SliderPrimitive.Range,
|
|
2675
|
+
{
|
|
2676
|
+
"data-slot": "slider-range",
|
|
2677
|
+
className: cn(
|
|
2678
|
+
"bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
|
|
2679
|
+
)
|
|
2680
|
+
}
|
|
2681
|
+
)
|
|
2682
|
+
}
|
|
2683
|
+
),
|
|
2684
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2685
|
+
SliderPrimitive.Thumb,
|
|
2686
|
+
{
|
|
2687
|
+
"data-slot": "slider-thumb",
|
|
2688
|
+
className: "border-primary ring-ring/50 relative block size-5 shrink-0 cursor-pointer touch-none 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"
|
|
2689
|
+
},
|
|
2690
|
+
index
|
|
2691
|
+
))
|
|
2692
|
+
]
|
|
2693
|
+
}
|
|
2694
|
+
);
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
// src/components/volume-controls.tsx
|
|
2698
|
+
var import_lucide_react5 = require("lucide-react");
|
|
2699
|
+
|
|
2700
|
+
// src/settings/platform-settings-runtime.tsx
|
|
2701
|
+
var import_react10 = require("react");
|
|
2702
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2703
|
+
var platformSettingsContext = (0, import_react10.createContext)(null);
|
|
2704
|
+
var createDefaultContextValue = () => ({
|
|
2705
|
+
mode: "default",
|
|
2706
|
+
status: "ready",
|
|
2707
|
+
settings: DEFAULT_PLATFORM_SETTINGS,
|
|
2708
|
+
setSettings: () => {
|
|
2709
|
+
throw new Error(
|
|
2710
|
+
'Platform settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
2711
|
+
);
|
|
2712
|
+
},
|
|
2713
|
+
updateSettings: () => {
|
|
2714
|
+
throw new Error(
|
|
2715
|
+
'Platform settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
2716
|
+
);
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2719
|
+
function usePlatformAudioSettings() {
|
|
2720
|
+
const context = (0, import_react10.useContext)(platformSettingsContext) ?? createDefaultContextValue();
|
|
2721
|
+
const { audio } = context.settings;
|
|
2722
|
+
const isReadOnly = context.mode !== "owner";
|
|
2723
|
+
const setAudioSetting = (0, import_react10.useCallback)(
|
|
2724
|
+
(patch) => {
|
|
2725
|
+
if (context.mode !== "owner") {
|
|
2726
|
+
throw new Error(
|
|
2727
|
+
'Platform audio settings are read-only in this runtime. Mount <PlatformSettingsRuntime persistence="local"> in the platform shell to update shared settings.'
|
|
2728
|
+
);
|
|
2729
|
+
}
|
|
2730
|
+
context.updateSettings({ audio: patch });
|
|
2731
|
+
},
|
|
2732
|
+
[context]
|
|
2733
|
+
);
|
|
2734
|
+
return {
|
|
2735
|
+
...audio,
|
|
2736
|
+
isReadOnly,
|
|
2737
|
+
getEffectiveVolume: (category) => getEffectiveAudioVolume(audio, category),
|
|
2738
|
+
setMasterVolume: (volume) => setAudioSetting({ masterVolume: volume }),
|
|
2739
|
+
setMusicVolume: (volume) => setAudioSetting({ musicVolume: volume }),
|
|
2740
|
+
setSfxVolume: (volume) => setAudioSetting({ sfxVolume: volume })
|
|
2741
|
+
};
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
// src/components/volume-controls.tsx
|
|
2745
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2746
|
+
function VolumeControls(props) {
|
|
2747
|
+
if (props.values) {
|
|
2748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ControlledVolumeControls, { ...props });
|
|
2749
|
+
}
|
|
2750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OwnedVolumeControls, { ...props });
|
|
2751
|
+
}
|
|
2752
|
+
function OwnedVolumeControls({ className, compact }) {
|
|
2753
|
+
const {
|
|
2754
|
+
masterVolume,
|
|
2755
|
+
musicVolume,
|
|
2756
|
+
sfxVolume,
|
|
2757
|
+
setMasterVolume,
|
|
2758
|
+
setMusicVolume,
|
|
2759
|
+
setSfxVolume
|
|
2760
|
+
} = usePlatformAudioSettings();
|
|
2761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2762
|
+
ControlledVolumeControls,
|
|
2763
|
+
{
|
|
2764
|
+
className,
|
|
2765
|
+
compact,
|
|
2766
|
+
values: { masterVolume, musicVolume, sfxVolume },
|
|
2767
|
+
onMasterVolumeChange: setMasterVolume,
|
|
2768
|
+
onMusicVolumeChange: setMusicVolume,
|
|
2769
|
+
onSfxVolumeChange: setSfxVolume,
|
|
2770
|
+
readOnly: false
|
|
2771
|
+
}
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2774
|
+
function ControlledVolumeControls({
|
|
2775
|
+
className,
|
|
2776
|
+
compact,
|
|
2777
|
+
values,
|
|
2778
|
+
readOnly = false,
|
|
2779
|
+
onMasterVolumeChange,
|
|
2780
|
+
onMusicVolumeChange,
|
|
2781
|
+
onSfxVolumeChange
|
|
2782
|
+
}) {
|
|
2783
|
+
if (!values) {
|
|
2784
|
+
throw new Error("ControlledVolumeControls requires values");
|
|
2785
|
+
}
|
|
2786
|
+
const { masterVolume, musicVolume, sfxVolume } = values;
|
|
2787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: cn("flex flex-col gap-3", compact && "gap-1", className), children: [
|
|
2788
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2789
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react5.Volume2, { className: "text-muted-foreground h-4 w-4" }),
|
|
2790
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-sm font-medium", children: "Volume" })
|
|
2791
|
+
] }),
|
|
2792
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2793
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2794
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { className: "text-muted-foreground text-xs", children: "Master" }),
|
|
2795
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2796
|
+
Math.round(masterVolume * 100),
|
|
2797
|
+
"%"
|
|
2798
|
+
] })
|
|
2799
|
+
] }),
|
|
2800
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2801
|
+
Slider,
|
|
2802
|
+
{
|
|
2803
|
+
"data-testid": "platform-settings-master-volume",
|
|
2804
|
+
value: [masterVolume * 100],
|
|
2805
|
+
onValueChange: (sliderValues) => onMasterVolumeChange?.(sliderValues[0] / 100),
|
|
2806
|
+
min: 0,
|
|
2807
|
+
max: 100,
|
|
2808
|
+
step: 1,
|
|
2809
|
+
className: "w-full",
|
|
2810
|
+
"aria-label": "Master volume",
|
|
2811
|
+
disabled: readOnly
|
|
2812
|
+
}
|
|
2813
|
+
)
|
|
2814
|
+
] }),
|
|
2815
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2816
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react5.Music, { className: "text-muted-foreground h-3 w-3" }),
|
|
2819
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { className: "text-muted-foreground text-xs", children: "Music" })
|
|
2820
|
+
] }),
|
|
2821
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2822
|
+
Math.round(musicVolume * 100),
|
|
2823
|
+
"%"
|
|
2824
|
+
] })
|
|
2825
|
+
] }),
|
|
2826
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2827
|
+
Slider,
|
|
2828
|
+
{
|
|
2829
|
+
"data-testid": "platform-settings-music-volume",
|
|
2830
|
+
value: [musicVolume * 100],
|
|
2831
|
+
onValueChange: (sliderValues) => onMusicVolumeChange?.(sliderValues[0] / 100),
|
|
2832
|
+
min: 0,
|
|
2833
|
+
max: 100,
|
|
2834
|
+
step: 1,
|
|
2835
|
+
className: "w-full",
|
|
2836
|
+
"aria-label": "Music volume",
|
|
2837
|
+
disabled: readOnly
|
|
2838
|
+
}
|
|
2839
|
+
)
|
|
2840
|
+
] }),
|
|
2841
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2842
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
2843
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2844
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react5.Headphones, { className: "text-muted-foreground h-3 w-3" }),
|
|
2845
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { className: "text-muted-foreground text-xs", children: "SFX" })
|
|
2846
|
+
] }),
|
|
2847
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "text-muted-foreground font-mono text-xs", children: [
|
|
2848
|
+
Math.round(sfxVolume * 100),
|
|
2849
|
+
"%"
|
|
2850
|
+
] })
|
|
2851
|
+
] }),
|
|
2852
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2853
|
+
Slider,
|
|
2854
|
+
{
|
|
2855
|
+
"data-testid": "platform-settings-sfx-volume",
|
|
2856
|
+
value: [sfxVolume * 100],
|
|
2857
|
+
onValueChange: (sliderValues) => onSfxVolumeChange?.(sliderValues[0] / 100),
|
|
2858
|
+
min: 0,
|
|
2859
|
+
max: 100,
|
|
2860
|
+
step: 1,
|
|
2861
|
+
className: "w-full",
|
|
2862
|
+
"aria-label": "SFX volume",
|
|
2863
|
+
disabled: readOnly
|
|
2864
|
+
}
|
|
2865
|
+
)
|
|
2866
|
+
] })
|
|
2867
|
+
] });
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
// src/hooks/use-controller-lifecycle-intents.ts
|
|
2871
|
+
var useControllerLifecycleIntents = ({
|
|
2872
|
+
onStart,
|
|
2873
|
+
onTogglePause,
|
|
2874
|
+
onBackToLobby,
|
|
2875
|
+
onRestart
|
|
2876
|
+
}) => {
|
|
2877
|
+
return {
|
|
2878
|
+
onStart,
|
|
2879
|
+
onTogglePause,
|
|
2880
|
+
onBackToLobby,
|
|
2881
|
+
onRestart
|
|
2882
|
+
};
|
|
2883
|
+
};
|
|
2884
|
+
|
|
2885
|
+
// src/hooks/use-controller-lifecycle-permissions.ts
|
|
2886
|
+
var useControllerLifecyclePermissions = ({
|
|
2887
|
+
phase,
|
|
2888
|
+
canStartMatch = false,
|
|
2889
|
+
canSendSystemCommand = false
|
|
2890
|
+
}) => {
|
|
2891
|
+
const canStart = phase === "lobby" && canStartMatch;
|
|
2892
|
+
const canPauseToggle = phase === "playing" && canSendSystemCommand;
|
|
2893
|
+
const canRestart = phase === "ended" && canSendSystemCommand;
|
|
2894
|
+
const canBackToLobby = phase !== "lobby" && canSendSystemCommand;
|
|
2895
|
+
const canInteractForPhase = phase === "lobby" ? canStart : canSendSystemCommand;
|
|
2896
|
+
return {
|
|
2897
|
+
canStart,
|
|
2898
|
+
canPauseToggle,
|
|
2899
|
+
canRestart,
|
|
2900
|
+
canBackToLobby,
|
|
2901
|
+
canInteractForPhase
|
|
2902
|
+
};
|
|
2903
|
+
};
|
|
2904
|
+
|
|
2905
|
+
// src/hooks/use-controller-shell-status.ts
|
|
2906
|
+
var useControllerShellStatus = ({
|
|
2907
|
+
roomId,
|
|
2908
|
+
connectionStatus,
|
|
2909
|
+
playerLabel,
|
|
2910
|
+
fallbackLabel = "Controller",
|
|
2911
|
+
roomFallback = "----"
|
|
2912
|
+
}) => {
|
|
2913
|
+
const trimmedLabel = playerLabel?.trim() ?? "";
|
|
2914
|
+
const displayName = trimmedLabel || fallbackLabel;
|
|
2915
|
+
const roomDisplay = roomId ?? roomFallback;
|
|
2916
|
+
const identityInitial = displayName.charAt(0).toUpperCase() || "M";
|
|
2917
|
+
return {
|
|
2918
|
+
connectionStatus,
|
|
2919
|
+
displayName,
|
|
2920
|
+
roomDisplay,
|
|
2921
|
+
roomLine: `Room ${roomDisplay}`,
|
|
2922
|
+
hasIdentity: trimmedLabel.length > 0,
|
|
2923
|
+
identityInitial
|
|
2924
|
+
};
|
|
2925
|
+
};
|
|
2926
|
+
|
|
2927
|
+
// src/hooks/use-host-join-controls.ts
|
|
2928
|
+
var import_react11 = require("react");
|
|
2929
|
+
var copyTextToClipboard = async (text) => {
|
|
2930
|
+
if (!text) {
|
|
2931
|
+
return false;
|
|
2932
|
+
}
|
|
2933
|
+
try {
|
|
2934
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
|
|
2935
|
+
await navigator.clipboard.writeText(text);
|
|
2936
|
+
return true;
|
|
2937
|
+
}
|
|
2938
|
+
} catch {
|
|
2939
|
+
}
|
|
2940
|
+
if (typeof document === "undefined") {
|
|
2941
|
+
return false;
|
|
2942
|
+
}
|
|
2943
|
+
const fallbackField = document.createElement("textarea");
|
|
2944
|
+
fallbackField.value = text;
|
|
2945
|
+
fallbackField.style.position = "fixed";
|
|
2946
|
+
fallbackField.style.opacity = "0";
|
|
2947
|
+
document.body.appendChild(fallbackField);
|
|
2948
|
+
fallbackField.select();
|
|
2949
|
+
try {
|
|
2950
|
+
return document.execCommand("copy");
|
|
2951
|
+
} catch {
|
|
2952
|
+
return false;
|
|
2953
|
+
} finally {
|
|
2954
|
+
document.body.removeChild(fallbackField);
|
|
2955
|
+
}
|
|
2956
|
+
};
|
|
2957
|
+
var useHostJoinControls = ({
|
|
2958
|
+
joinUrl,
|
|
2959
|
+
canStartMatch = false,
|
|
2960
|
+
onStartMatch,
|
|
2961
|
+
copiedDurationMs = 1800
|
|
2962
|
+
}) => {
|
|
2963
|
+
const [copied, setCopied] = (0, import_react11.useState)(false);
|
|
2964
|
+
const [joinQrVisible, setJoinQrVisible] = (0, import_react11.useState)(false);
|
|
2965
|
+
const resetTimerRef = (0, import_react11.useRef)(null);
|
|
2966
|
+
const joinUrlValue = (0, import_react11.useMemo)(() => joinUrl ?? "", [joinUrl]);
|
|
2967
|
+
const hasJoinUrl = joinUrlValue.length > 0;
|
|
2968
|
+
(0, import_react11.useEffect)(() => {
|
|
2969
|
+
if (!hasJoinUrl) {
|
|
2970
|
+
setJoinQrVisible(false);
|
|
2971
|
+
}
|
|
2972
|
+
}, [hasJoinUrl]);
|
|
2973
|
+
const handleCopy = (0, import_react11.useCallback)(async () => {
|
|
2974
|
+
if (!joinUrlValue) {
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
const copiedSuccessfully = await copyTextToClipboard(joinUrlValue);
|
|
2978
|
+
if (!copiedSuccessfully || typeof window === "undefined") {
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
setCopied(true);
|
|
2982
|
+
if (resetTimerRef.current !== null) {
|
|
2983
|
+
window.clearTimeout(resetTimerRef.current);
|
|
2984
|
+
}
|
|
2985
|
+
resetTimerRef.current = window.setTimeout(() => {
|
|
2986
|
+
setCopied(false);
|
|
2987
|
+
resetTimerRef.current = null;
|
|
2988
|
+
}, copiedDurationMs);
|
|
2989
|
+
}, [copiedDurationMs, joinUrlValue]);
|
|
2990
|
+
const handleOpen = (0, import_react11.useCallback)(() => {
|
|
2991
|
+
if (!joinUrlValue || typeof window === "undefined") {
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
window.open(joinUrlValue, "_blank", "noopener,noreferrer");
|
|
2995
|
+
}, [joinUrlValue]);
|
|
2996
|
+
const showJoinQr = (0, import_react11.useCallback)(() => {
|
|
2997
|
+
if (!hasJoinUrl) {
|
|
2998
|
+
return;
|
|
2999
|
+
}
|
|
3000
|
+
setJoinQrVisible(true);
|
|
3001
|
+
}, [hasJoinUrl]);
|
|
3002
|
+
const hideJoinQr = (0, import_react11.useCallback)(() => {
|
|
3003
|
+
setJoinQrVisible(false);
|
|
3004
|
+
}, []);
|
|
3005
|
+
const toggleJoinQr = (0, import_react11.useCallback)(() => {
|
|
3006
|
+
if (!hasJoinUrl) {
|
|
3007
|
+
return;
|
|
3008
|
+
}
|
|
3009
|
+
setJoinQrVisible((current) => !current);
|
|
3010
|
+
}, [hasJoinUrl]);
|
|
3011
|
+
const handleStart = (0, import_react11.useCallback)(() => {
|
|
3012
|
+
if (!canStartMatch) {
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
onStartMatch?.();
|
|
3016
|
+
}, [canStartMatch, onStartMatch]);
|
|
3017
|
+
return {
|
|
3018
|
+
joinUrlValue,
|
|
3019
|
+
hasJoinUrl,
|
|
3020
|
+
copied,
|
|
3021
|
+
joinQrVisible,
|
|
3022
|
+
canStartMatch,
|
|
3023
|
+
handleCopy,
|
|
3024
|
+
handleOpen,
|
|
3025
|
+
showJoinQr,
|
|
3026
|
+
hideJoinQr,
|
|
3027
|
+
toggleJoinQr,
|
|
3028
|
+
handleStart
|
|
3029
|
+
};
|
|
3030
|
+
};
|
|
3031
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3032
|
+
0 && (module.exports = {
|
|
3033
|
+
AIRJAM_DEFAULT_AVATAR_SEEDS,
|
|
3034
|
+
Button,
|
|
3035
|
+
ConnectionStatusPill,
|
|
3036
|
+
ControllerPlayerNameField,
|
|
3037
|
+
ControllerPrimaryAction,
|
|
3038
|
+
HostMuteButton,
|
|
3039
|
+
JoinQrOverlay,
|
|
3040
|
+
JoinUrlActionButtons,
|
|
3041
|
+
JoinUrlControls,
|
|
3042
|
+
JoinUrlField,
|
|
3043
|
+
LifecycleActionGroup,
|
|
3044
|
+
PlayerAvatar,
|
|
3045
|
+
PlayerAvatarStrip,
|
|
3046
|
+
RoomQrCode,
|
|
3047
|
+
RuntimeShellHeader,
|
|
3048
|
+
Slider,
|
|
3049
|
+
SurfaceViewport,
|
|
3050
|
+
VolumeControls,
|
|
3051
|
+
buttonVariants,
|
|
3052
|
+
getDiceBearAdventurerNeutralUrl,
|
|
3053
|
+
getPlayerAvatarImageUrl,
|
|
3054
|
+
resolvePlayerAvatarSeed,
|
|
3055
|
+
useControllerLifecycleIntents,
|
|
3056
|
+
useControllerLifecyclePermissions,
|
|
3057
|
+
useControllerShellStatus,
|
|
3058
|
+
useHostJoinControls,
|
|
3059
|
+
useLifecycleActionGroupModel
|
|
3060
|
+
});
|
|
3061
|
+
//# sourceMappingURL=ui.cjs.map
|