@air-jam/sdk 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/arcade/bridge/controller.cjs +1 -1
  2. package/dist/arcade/bridge/controller.js +2 -2
  3. package/dist/arcade/bridge/host.cjs +1 -1
  4. package/dist/arcade/bridge/host.js +2 -2
  5. package/dist/arcade/bridge/iframe.cjs +1 -1
  6. package/dist/arcade/bridge/iframe.js +5 -5
  7. package/dist/arcade/bridge.cjs +1 -1
  8. package/dist/arcade/bridge.js +8 -8
  9. package/dist/arcade/host.cjs +0 -7
  10. package/dist/arcade/host.cjs.map +1 -1
  11. package/dist/arcade/host.js +4 -3
  12. package/dist/arcade/url.cjs +183 -2
  13. package/dist/arcade/url.cjs.map +1 -1
  14. package/dist/arcade/url.d.cts +1 -1
  15. package/dist/arcade/url.d.ts +1 -1
  16. package/dist/arcade/url.js +5 -4
  17. package/dist/arcade.cjs +184 -12
  18. package/dist/arcade.cjs.map +1 -1
  19. package/dist/arcade.d.cts +1 -1
  20. package/dist/arcade.d.ts +1 -1
  21. package/dist/arcade.js +22 -21
  22. package/dist/{chunk-2432OL7L.js → chunk-6CMB356F.js} +2 -2
  23. package/dist/{chunk-Y4RAPKKB.js → chunk-7OTQTT6H.js} +2 -2
  24. package/dist/{chunk-VDRNNGHX.js → chunk-CVYR5RJT.js} +9 -9
  25. package/dist/{chunk-VDRNNGHX.js.map → chunk-CVYR5RJT.js.map} +1 -1
  26. package/dist/{chunk-CQUG24WX.js → chunk-DY67S3LR.js} +2 -2
  27. package/dist/{chunk-NU5W6VAV.js → chunk-E5PVHEAX.js} +3 -3
  28. package/dist/{chunk-XLUWV45V.js → chunk-EDRQIOCV.js} +2 -2
  29. package/dist/{chunk-2J65FXEP.js → chunk-JO2HR5PV.js} +6 -4
  30. package/dist/chunk-JO2HR5PV.js.map +1 -0
  31. package/dist/{chunk-MKBASO6X.js → chunk-KOB73SPD.js} +2 -2
  32. package/dist/{chunk-VN5LDWVN.js → chunk-M4DKOI42.js} +2 -2
  33. package/dist/{chunk-HFWRZVZ3.js → chunk-NUJBMV3O.js} +13 -16
  34. package/dist/chunk-NUJBMV3O.js.map +1 -0
  35. package/dist/{chunk-D3X4MN4U.js → chunk-Q4UALQO4.js} +2 -2
  36. package/dist/chunk-UWJOIVON.js +369 -0
  37. package/dist/chunk-UWJOIVON.js.map +1 -0
  38. package/dist/index.cjs +515 -123
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +9 -2
  41. package/dist/index.d.ts +9 -2
  42. package/dist/index.js +175 -102
  43. package/dist/index.js.map +1 -1
  44. package/dist/preview.cjs +22 -11
  45. package/dist/preview.cjs.map +1 -1
  46. package/dist/preview.d.cts +1 -1
  47. package/dist/preview.d.ts +1 -1
  48. package/dist/preview.js +12 -12
  49. package/dist/preview.js.map +1 -1
  50. package/dist/runtime-topology.cjs +405 -0
  51. package/dist/runtime-topology.cjs.map +1 -0
  52. package/dist/runtime-topology.d.cts +59 -0
  53. package/dist/runtime-topology.d.ts +59 -0
  54. package/dist/runtime-topology.js +31 -0
  55. package/dist/runtime-topology.js.map +1 -0
  56. package/dist/ui.cjs +341 -30
  57. package/dist/ui.cjs.map +1 -1
  58. package/dist/ui.d.cts +11 -1
  59. package/dist/ui.d.ts +11 -1
  60. package/dist/ui.js +110 -32
  61. package/dist/ui.js.map +1 -1
  62. package/package.json +10 -3
  63. package/src/arcade/url.ts +2 -2
  64. package/src/components/join-qr-overlay.tsx +115 -31
  65. package/src/context/air-jam-context.tsx +2 -2
  66. package/src/dev/browser-log-sink.ts +1 -1
  67. package/src/hooks/use-host-audio-mute-preference.ts +99 -0
  68. package/src/index.ts +4 -0
  69. package/src/preview/ownership.ts +1 -1
  70. package/src/runtime/air-jam-config.ts +1 -1
  71. package/src/runtime/create-air-jam-app.tsx +2 -2
  72. package/src/runtime/embedded-runtime-adapters.ts +1 -1
  73. package/src/runtime/runtime-session-params.ts +2 -2
  74. package/src/runtime-topology.ts +569 -0
  75. package/dist/chunk-2J65FXEP.js.map +0 -1
  76. package/dist/chunk-HFWRZVZ3.js.map +0 -1
  77. /package/dist/{chunk-2432OL7L.js.map → chunk-6CMB356F.js.map} +0 -0
  78. /package/dist/{chunk-Y4RAPKKB.js.map → chunk-7OTQTT6H.js.map} +0 -0
  79. /package/dist/{chunk-CQUG24WX.js.map → chunk-DY67S3LR.js.map} +0 -0
  80. /package/dist/{chunk-NU5W6VAV.js.map → chunk-E5PVHEAX.js.map} +0 -0
  81. /package/dist/{chunk-XLUWV45V.js.map → chunk-EDRQIOCV.js.map} +0 -0
  82. /package/dist/{chunk-MKBASO6X.js.map → chunk-KOB73SPD.js.map} +0 -0
  83. /package/dist/{chunk-VN5LDWVN.js.map → chunk-M4DKOI42.js.map} +0 -0
  84. /package/dist/{chunk-D3X4MN4U.js.map → chunk-Q4UALQO4.js.map} +0 -0
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  readChildHostRuntimeParams,
3
3
  readEmbeddedControllerRuntimeParams,
4
4
  useAirJamController
5
- } from "./chunk-VDRNNGHX.js";
5
+ } from "./chunk-CVYR5RJT.js";
6
6
  import {
7
7
  agentAction,
8
8
  agentActionInput,
@@ -19,10 +19,7 @@ import {
19
19
  parseHostBridgeCloseMessage,
20
20
  parseHostBridgeEventMessage,
21
21
  parseHostBridgeResponseMessage
22
- } from "./chunk-2432OL7L.js";
23
- import {
24
- urlBuilder
25
- } from "./chunk-YXHH3MQT.js";
22
+ } from "./chunk-6CMB356F.js";
26
23
  import {
27
24
  createControllerBridgeCloseMessage,
28
25
  createControllerBridgeEmitMessage,
@@ -31,7 +28,10 @@ import {
31
28
  parseControllerBridgeCloseMessage,
32
29
  parseControllerBridgeEventMessage,
33
30
  parseControllerBridgeResponseMessage
34
- } from "./chunk-MKBASO6X.js";
31
+ } from "./chunk-KOB73SPD.js";
32
+ import {
33
+ urlBuilder
34
+ } from "./chunk-YXHH3MQT.js";
35
35
  import "./chunk-X24K52DG.js";
36
36
  import {
37
37
  AIR_JAM_PREVIEW_CLOSE_RESULT,
@@ -39,7 +39,7 @@ import {
39
39
  isPreviewCloseRequestMessage,
40
40
  readPreviewControllerDeviceIdFromLocation,
41
41
  useAirJamHost
42
- } from "./chunk-NU5W6VAV.js";
42
+ } from "./chunk-E5PVHEAX.js";
43
43
  import {
44
44
  PlatformSettingsBoundary,
45
45
  PlatformSettingsRuntime,
@@ -50,8 +50,9 @@ import {
50
50
  usePlatformSettings,
51
51
  usePlatformSettingsRuntimeStatus,
52
52
  useResolvedPlatformSettingsSnapshot
53
- } from "./chunk-D3X4MN4U.js";
54
- import "./chunk-Y4RAPKKB.js";
53
+ } from "./chunk-Q4UALQO4.js";
54
+ import "./chunk-7OTQTT6H.js";
55
+ import "./chunk-DY67S3LR.js";
55
56
  import {
56
57
  AirJamProvider,
57
58
  RuntimeOwnerRegistryContext,
@@ -65,19 +66,10 @@ import {
65
66
  useAirJamState,
66
67
  useAssertSessionScope,
67
68
  useClaimSessionRuntimeOwner
68
- } from "./chunk-HFWRZVZ3.js";
69
+ } from "./chunk-NUJBMV3O.js";
69
70
  import {
70
71
  emitAirJamDevRuntimeEvent
71
72
  } from "./chunk-LIXPF4P6.js";
72
- import {
73
- CONTROLLER_PATH
74
- } from "./chunk-W2VK36RO.js";
75
- import {
76
- AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN,
77
- AIR_JAM_DEFAULT_STORE_DOMAIN,
78
- resolveImplicitReplicatedStoreDomainFromWindow
79
- } from "./chunk-BE6Z4SIT.js";
80
- import "./chunk-CQUG24WX.js";
81
73
  import {
82
74
  DEFAULT_PLATFORM_SETTINGS,
83
75
  DEFAULT_ROOM_PLATFORM_SETTINGS,
@@ -100,7 +92,18 @@ import {
100
92
  playerProfilePatchSchema,
101
93
  roomCodeSchema
102
94
  } from "./chunk-32NYL7XI.js";
95
+ import {
96
+ CONTROLLER_PATH
97
+ } from "./chunk-W2VK36RO.js";
98
+ import {
99
+ resolveProjectRuntimeTopology
100
+ } from "./chunk-UWJOIVON.js";
103
101
  import "./chunk-3USU7GY2.js";
102
+ import {
103
+ AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN,
104
+ AIR_JAM_DEFAULT_STORE_DOMAIN,
105
+ resolveImplicitReplicatedStoreDomainFromWindow
106
+ } from "./chunk-BE6Z4SIT.js";
104
107
 
105
108
  // src/audio/hooks.tsx
106
109
  import {
@@ -1729,8 +1732,78 @@ var useHostTick = (options) => {
1729
1732
  }, [enabled, mode, tickIntervalMs, frameDeltaCapMs, frameStepCap]);
1730
1733
  };
1731
1734
 
1735
+ // src/hooks/use-host-audio-mute-preference.ts
1736
+ import { useCallback as useCallback4, useEffect as useEffect6, useMemo as useMemo4, useState as useState3 } from "react";
1737
+ var HOST_AUDIO_MUTE_STORAGE_KEY_PREFIX = "air-jam-host-audio-muted:";
1738
+ var getHostAudioMuteStorageKey = (scope) => `${HOST_AUDIO_MUTE_STORAGE_KEY_PREFIX}${scope}`;
1739
+ var readHostAudioMutePreference = (storageKey, fallback) => {
1740
+ if (typeof window === "undefined") {
1741
+ return fallback;
1742
+ }
1743
+ const raw = window.localStorage.getItem(storageKey);
1744
+ if (raw === "true") {
1745
+ return true;
1746
+ }
1747
+ if (raw === "false") {
1748
+ return false;
1749
+ }
1750
+ return fallback;
1751
+ };
1752
+ var persistHostAudioMutePreference = (storageKey, muted) => {
1753
+ if (typeof window === "undefined") {
1754
+ return;
1755
+ }
1756
+ window.localStorage.setItem(storageKey, muted ? "true" : "false");
1757
+ };
1758
+ var useHostAudioMutePreference = (scope, defaultMuted = false) => {
1759
+ const storageKey = useMemo4(() => getHostAudioMuteStorageKey(scope), [scope]);
1760
+ const [muted, setMutedState] = useState3(
1761
+ () => readHostAudioMutePreference(storageKey, defaultMuted)
1762
+ );
1763
+ useEffect6(() => {
1764
+ setMutedState(readHostAudioMutePreference(storageKey, defaultMuted));
1765
+ }, [defaultMuted, storageKey]);
1766
+ useEffect6(() => {
1767
+ if (typeof window === "undefined") {
1768
+ return;
1769
+ }
1770
+ const handleStorage = (event) => {
1771
+ if (event.storageArea !== window.localStorage) {
1772
+ return;
1773
+ }
1774
+ if (event.key !== storageKey) {
1775
+ return;
1776
+ }
1777
+ setMutedState(readHostAudioMutePreference(storageKey, defaultMuted));
1778
+ };
1779
+ window.addEventListener("storage", handleStorage);
1780
+ return () => {
1781
+ window.removeEventListener("storage", handleStorage);
1782
+ };
1783
+ }, [defaultMuted, storageKey]);
1784
+ const setMuted = useCallback4(
1785
+ (nextMuted) => {
1786
+ setMutedState(nextMuted);
1787
+ persistHostAudioMutePreference(storageKey, nextMuted);
1788
+ },
1789
+ [storageKey]
1790
+ );
1791
+ const toggleMuted = useCallback4(() => {
1792
+ setMutedState((current) => {
1793
+ const nextMuted = !current;
1794
+ persistHostAudioMutePreference(storageKey, nextMuted);
1795
+ return nextMuted;
1796
+ });
1797
+ }, [storageKey]);
1798
+ return {
1799
+ muted,
1800
+ setMuted,
1801
+ toggleMuted
1802
+ };
1803
+ };
1804
+
1732
1805
  // src/hooks/use-input-writer.ts
1733
- import { useCallback as useCallback4 } from "react";
1806
+ import { useCallback as useCallback5 } from "react";
1734
1807
 
1735
1808
  // src/utils/is-rpc-serializable.ts
1736
1809
  var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
@@ -1777,7 +1850,7 @@ var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
1777
1850
  var useInputWriter = () => {
1778
1851
  useAssertSessionScope("controller", "useInputWriter");
1779
1852
  const { store, getSocket } = useAirJamContext();
1780
- return useCallback4(
1853
+ return useCallback5(
1781
1854
  (input) => {
1782
1855
  if (typeof input !== "object" || input === null || Array.isArray(input)) {
1783
1856
  emitAirJamDiagnostic({
@@ -1863,11 +1936,11 @@ var useRoom = () => {
1863
1936
  };
1864
1937
 
1865
1938
  // src/hooks/use-send-signal.ts
1866
- import { useCallback as useCallback5 } from "react";
1939
+ import { useCallback as useCallback6 } from "react";
1867
1940
  var useSendSignal = () => {
1868
1941
  useAssertSessionScope("host", "useSendSignal");
1869
1942
  const { getSocket } = useAirJamContext();
1870
- const sendSignal = useCallback5(
1943
+ const sendSignal = useCallback6(
1871
1944
  (type, payload, targetId) => {
1872
1945
  const socket = getHostRealtimeClient((role) => getSocket(role));
1873
1946
  if (!socket || !socket.connected) {
@@ -1939,10 +2012,10 @@ var useHostRuntimeInspectionContract = () => createHostRuntimeInspectionContract
1939
2012
  var useControllerRuntimeInspectionContract = () => createControllerRuntimeInspectionContract(useAirJamController());
1940
2013
 
1941
2014
  // src/runtime/session-runtimes.tsx
1942
- import { useEffect as useEffect8 } from "react";
2015
+ import { useEffect as useEffect9 } from "react";
1943
2016
 
1944
2017
  // src/context/session-providers.tsx
1945
- import { useCallback as useCallback6, useRef as useRef5 } from "react";
2018
+ import { useCallback as useCallback7, useRef as useRef5 } from "react";
1946
2019
  import { jsx as jsx2 } from "react/jsx-runtime";
1947
2020
  var createScopedSessionProvider = (scope) => {
1948
2021
  const ScopedSessionProvider = ({
@@ -1950,7 +2023,7 @@ var createScopedSessionProvider = (scope) => {
1950
2023
  ...providerProps
1951
2024
  }) => {
1952
2025
  const runtimeOwnersRef = useRef5(/* @__PURE__ */ new Map());
1953
- const claimOwner = useCallback6(
2026
+ const claimOwner = useCallback7(
1954
2027
  (kind, token, hookName) => {
1955
2028
  const existing = runtimeOwnersRef.current.get(kind);
1956
2029
  if (existing && existing.token !== token) {
@@ -1983,7 +2056,7 @@ var HostSessionProvider = createScopedSessionProvider("host");
1983
2056
  var ControllerSessionProvider = createScopedSessionProvider("controller");
1984
2057
 
1985
2058
  // src/hooks/internal/use-controller-runtime-api.ts
1986
- import { useCallback as useCallback7, useEffect as useEffect6, useMemo as useMemo4, useRef as useRef6, useState as useState3 } from "react";
2059
+ import { useCallback as useCallback8, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef6, useState as useState4 } from "react";
1987
2060
  import { useStore as useStore5 } from "zustand";
1988
2061
 
1989
2062
  // src/runtime/controller-identity.ts
@@ -2156,27 +2229,27 @@ var useControllerRuntimeApi = (options, hookName) => {
2156
2229
  const { store, getSocket, disconnectSocket } = useAirJamContext();
2157
2230
  const nicknameRef = useRef6(options.nickname ?? "");
2158
2231
  const avatarIdRef = useRef6(options.avatarId ?? "");
2159
- useEffect6(() => {
2232
+ useEffect7(() => {
2160
2233
  nicknameRef.current = options.nickname ?? "";
2161
2234
  }, [options.nickname]);
2162
- useEffect6(() => {
2235
+ useEffect7(() => {
2163
2236
  avatarIdRef.current = options.avatarId ?? "";
2164
2237
  }, [options.avatarId]);
2165
- const embeddedController = useMemo4(
2238
+ const embeddedController = useMemo5(
2166
2239
  () => readEmbeddedControllerChildSession(),
2167
2240
  []
2168
2241
  );
2169
- const urlRoomId = useMemo4(() => getRoomFromLocation(), []);
2170
- const locationCapabilityToken = useMemo4(
2242
+ const urlRoomId = useMemo5(() => getRoomFromLocation(), []);
2243
+ const locationCapabilityToken = useMemo5(
2171
2244
  () => getControllerCapabilityTokenFromLocation(),
2172
2245
  []
2173
2246
  );
2174
2247
  const capabilityToken = options.capabilityToken === void 0 ? locationCapabilityToken : options.capabilityToken;
2175
- const previewDeviceId = useMemo4(
2248
+ const previewDeviceId = useMemo5(
2176
2249
  () => readPreviewControllerDeviceIdFromLocation(),
2177
2250
  []
2178
2251
  );
2179
- const joinSource = useMemo4(
2252
+ const joinSource = useMemo5(
2180
2253
  () => resolveControllerJoinSource({
2181
2254
  embeddedRoomId: embeddedController?.roomId,
2182
2255
  optionRoomId: options.roomId ?? null,
@@ -2184,7 +2257,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2184
2257
  }),
2185
2258
  [embeddedController?.roomId, options.roomId, urlRoomId]
2186
2259
  );
2187
- const parsedRoomId = useMemo4(() => {
2260
+ const parsedRoomId = useMemo5(() => {
2188
2261
  const code = embeddedController?.roomId ?? options.roomId ?? urlRoomId;
2189
2262
  if (!code) return null;
2190
2263
  try {
@@ -2193,7 +2266,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2193
2266
  return null;
2194
2267
  }
2195
2268
  }, [options.roomId, embeddedController, urlRoomId]);
2196
- const deviceId = useMemo4(() => {
2269
+ const deviceId = useMemo5(() => {
2197
2270
  if (embeddedController) {
2198
2271
  return null;
2199
2272
  }
@@ -2202,7 +2275,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2202
2275
  }
2203
2276
  return getOrCreateControllerDeviceId();
2204
2277
  }, [embeddedController, previewDeviceId]);
2205
- const controllerId = useMemo4(() => {
2278
+ const controllerId = useMemo5(() => {
2206
2279
  if (embeddedController?.controllerId) {
2207
2280
  return embeddedController.controllerId;
2208
2281
  }
@@ -2225,11 +2298,11 @@ var useControllerRuntimeApi = (options, hookName) => {
2225
2298
  const onStateRef = useRef6(
2226
2299
  options.onState
2227
2300
  );
2228
- useEffect6(() => {
2301
+ useEffect7(() => {
2229
2302
  onStateRef.current = options.onState;
2230
2303
  }, [options.onState]);
2231
2304
  const activeControllerId = useStore5(store, (state) => state.controllerId);
2232
- useEffect6(() => {
2305
+ useEffect7(() => {
2233
2306
  updateDevBrowserLogContext({
2234
2307
  role: "controller",
2235
2308
  traceId: void 0,
@@ -2237,7 +2310,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2237
2310
  controllerId: activeControllerId ?? controllerId ?? void 0
2238
2311
  });
2239
2312
  }, [activeControllerId, controllerId, parsedRoomId]);
2240
- useEffect6(() => {
2313
+ useEffect7(() => {
2241
2314
  return () => {
2242
2315
  updateDevBrowserLogContext({
2243
2316
  role: void 0,
@@ -2246,9 +2319,9 @@ var useControllerRuntimeApi = (options, hookName) => {
2246
2319
  });
2247
2320
  };
2248
2321
  }, []);
2249
- const [reconnectKey, setReconnectKey] = useState3(0);
2322
+ const [reconnectKey, setReconnectKey] = useState4(0);
2250
2323
  const leaveIssuedRef = useRef6(false);
2251
- const emitControllerRuntimeEvent = useCallback7(
2324
+ const emitControllerRuntimeEvent = useCallback8(
2252
2325
  ({
2253
2326
  event,
2254
2327
  level = "info",
@@ -2270,7 +2343,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2270
2343
  );
2271
2344
  const lastObservedStateVersionRef = useRef6(null);
2272
2345
  const emittedInvariantKeysRef = useRef6(/* @__PURE__ */ new Set());
2273
- const emitInvariantOnce = useCallback7(
2346
+ const emitInvariantOnce = useCallback8(
2274
2347
  ({
2275
2348
  code,
2276
2349
  roomId,
@@ -2295,11 +2368,11 @@ var useControllerRuntimeApi = (options, hookName) => {
2295
2368
  },
2296
2369
  [emitControllerRuntimeEvent]
2297
2370
  );
2298
- const socket = useMemo4(
2371
+ const socket = useMemo5(
2299
2372
  () => parsedRoomId ? getControllerRealtimeClient((role) => getSocket(role)) : null,
2300
2373
  [parsedRoomId, getSocket]
2301
2374
  );
2302
- const reconnect = useCallback7(() => {
2375
+ const reconnect = useCallback8(() => {
2303
2376
  if (!parsedRoomId) return;
2304
2377
  socket?.disconnect();
2305
2378
  if (!embeddedController) {
@@ -2307,7 +2380,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2307
2380
  }
2308
2381
  setReconnectKey((prev) => prev + 1);
2309
2382
  }, [parsedRoomId, disconnectSocket, socket, embeddedController]);
2310
- const leave = useCallback7(async () => {
2383
+ const leave = useCallback8(async () => {
2311
2384
  const storeState = store.getState();
2312
2385
  const activeControllerId2 = storeState.controllerId;
2313
2386
  if (!socket || !parsedRoomId || !activeControllerId2) {
@@ -2355,7 +2428,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2355
2428
  );
2356
2429
  });
2357
2430
  }, [embeddedController, parsedRoomId, socket, store]);
2358
- useEffect6(() => {
2431
+ useEffect7(() => {
2359
2432
  if (!socket) return;
2360
2433
  const handleSignal = (signal) => {
2361
2434
  if (signal.type !== "HAPTIC") return;
@@ -2391,7 +2464,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2391
2464
  socket.off("server:signal", handleSignal);
2392
2465
  };
2393
2466
  }, [socket]);
2394
- useEffect6(() => {
2467
+ useEffect7(() => {
2395
2468
  if (typeof window === "undefined" || !previewDeviceId || embeddedController || !socket) {
2396
2469
  return;
2397
2470
  }
@@ -2419,7 +2492,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2419
2492
  window.removeEventListener("message", handleMessage);
2420
2493
  };
2421
2494
  }, [disconnectSocket, embeddedController, leave, previewDeviceId, socket]);
2422
- useEffect6(() => {
2495
+ useEffect7(() => {
2423
2496
  if (!previewDeviceId || !parsedRoomId || embeddedController || !socket) {
2424
2497
  return;
2425
2498
  }
@@ -2440,7 +2513,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2440
2513
  );
2441
2514
  };
2442
2515
  }, [embeddedController, parsedRoomId, previewDeviceId, socket, store]);
2443
- useEffect6(() => {
2516
+ useEffect7(() => {
2444
2517
  const storeState = store.getState();
2445
2518
  storeState.setMode(detectRunMode());
2446
2519
  storeState.setRole("controller");
@@ -2732,13 +2805,13 @@ var useControllerRuntimeApi = (options, hookName) => {
2732
2805
  capabilityToken,
2733
2806
  emitInvariantOnce
2734
2807
  ]);
2735
- const setNickname = useCallback7((value) => {
2808
+ const setNickname = useCallback8((value) => {
2736
2809
  nicknameRef.current = value;
2737
2810
  }, []);
2738
- const setAvatarId = useCallback7((value) => {
2811
+ const setAvatarId = useCallback8((value) => {
2739
2812
  avatarIdRef.current = value;
2740
2813
  }, []);
2741
- const updatePlayerProfile = useCallback7(
2814
+ const updatePlayerProfile = useCallback8(
2742
2815
  (patch) => {
2743
2816
  const parsedPatch = playerProfilePatchSchema.safeParse(patch);
2744
2817
  if (!parsedPatch.success) {
@@ -2775,7 +2848,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2775
2848
  },
2776
2849
  [parsedRoomId, socket, store, embeddedController]
2777
2850
  );
2778
- const sendSystemCommand = useCallback7(
2851
+ const sendSystemCommand = useCallback8(
2779
2852
  (command) => {
2780
2853
  const storeState = store.getState();
2781
2854
  if (!parsedRoomId || !storeState.controllerId || !socket) return;
@@ -2790,7 +2863,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2790
2863
  },
2791
2864
  [parsedRoomId, socket, store]
2792
2865
  );
2793
- return useMemo4(
2866
+ return useMemo5(
2794
2867
  () => ({
2795
2868
  sendSystemCommand,
2796
2869
  setNickname,
@@ -2813,7 +2886,7 @@ var useControllerRuntimeApi = (options, hookName) => {
2813
2886
  };
2814
2887
 
2815
2888
  // src/hooks/internal/use-host-runtime-api.ts
2816
- import { useCallback as useCallback8, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef7, useState as useState4 } from "react";
2889
+ import { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo6, useRef as useRef7, useState as useState5 } from "react";
2817
2890
  import { z as zod } from "zod";
2818
2891
  import { useStore as useStore6 } from "zustand";
2819
2892
  var HOST_BOOTSTRAP_TIMEOUT_MESSAGE = "Host bootstrap timed out. The deployed Air Jam server may be out of sync with this client.";
@@ -2821,10 +2894,10 @@ var useHostRuntimeApi = (options, hookName) => {
2821
2894
  useAssertSessionScope("host", hookName);
2822
2895
  useClaimSessionRuntimeOwner("host-runtime", hookName);
2823
2896
  const { config, store, getSocket, disconnectSocket, inputManager } = useAirJamContext();
2824
- const embeddedHost = useMemo5(() => readEmbeddedHostChildSession(), []);
2897
+ const embeddedHost = useMemo6(() => readEmbeddedHostChildSession(), []);
2825
2898
  const shouldConnect = true;
2826
2899
  const storeRoomId = useStore6(store, (s) => s.roomId);
2827
- const parsedRoomId = useMemo5(() => {
2900
+ const parsedRoomId = useMemo6(() => {
2828
2901
  if (embeddedHost) {
2829
2902
  return embeddedHost.roomId;
2830
2903
  }
@@ -2844,12 +2917,12 @@ var useHostRuntimeApi = (options, hookName) => {
2844
2917
  }
2845
2918
  return null;
2846
2919
  }, [options.roomId, storeRoomId, embeddedHost]);
2847
- const [controllerCapability, setControllerCapability] = useState4(null);
2848
- const joinUrlBuildKey = useMemo5(
2920
+ const [controllerCapability, setControllerCapability] = useState5(null);
2921
+ const joinUrlBuildKey = useMemo6(
2849
2922
  () => parsedRoomId ? `${parsedRoomId}\0${config.publicHost ?? ""}\0${controllerCapability?.token ?? ""}` : null,
2850
2923
  [config.publicHost, controllerCapability?.token, parsedRoomId]
2851
2924
  );
2852
- const [computedJoinUrl, setComputedJoinUrl] = useState4({
2925
+ const [computedJoinUrl, setComputedJoinUrl] = useState5({
2853
2926
  key: null,
2854
2927
  url: "",
2855
2928
  error: false
@@ -2857,19 +2930,19 @@ var useHostRuntimeApi = (options, hookName) => {
2857
2930
  const onPlayerJoinRef = useRef7(options.onPlayerJoin);
2858
2931
  const onPlayerLeaveRef = useRef7(options.onPlayerLeave);
2859
2932
  const parsedRoomIdRef = useRef7(parsedRoomId);
2860
- useEffect7(() => {
2933
+ useEffect8(() => {
2861
2934
  onPlayerJoinRef.current = options.onPlayerJoin;
2862
2935
  onPlayerLeaveRef.current = options.onPlayerLeave;
2863
2936
  }, [options.onPlayerJoin, options.onPlayerLeave]);
2864
- useEffect7(() => {
2937
+ useEffect8(() => {
2865
2938
  parsedRoomIdRef.current = parsedRoomId;
2866
2939
  }, [parsedRoomId]);
2867
- const socket = useMemo5(
2940
+ const socket = useMemo6(
2868
2941
  () => shouldConnect ? getHostRealtimeClient((role) => getSocket(role)) : null,
2869
2942
  [shouldConnect, getSocket]
2870
2943
  );
2871
2944
  const setRegisteredRoomId = useStore6(store, (s) => s.setRegisteredRoomId);
2872
- const hydrateHostRoster = useCallback8(
2945
+ const hydrateHostRoster = useCallback9(
2873
2946
  (players, controllers) => {
2874
2947
  const latestState = store.getState();
2875
2948
  latestState.resetPlayers();
@@ -2883,7 +2956,7 @@ var useHostRuntimeApi = (options, hookName) => {
2883
2956
  },
2884
2957
  [store]
2885
2958
  );
2886
- const canEmitAuthoritativeHostState = useCallback8(
2959
+ const canEmitAuthoritativeHostState = useCallback9(
2887
2960
  (roomId) => {
2888
2961
  if (!socket || !socket.connected || !roomId) {
2889
2962
  return false;
@@ -2893,7 +2966,7 @@ var useHostRuntimeApi = (options, hookName) => {
2893
2966
  },
2894
2967
  [socket, store]
2895
2968
  );
2896
- const emitHostRuntimeEvent = useCallback8(
2969
+ const emitHostRuntimeEvent = useCallback9(
2897
2970
  ({
2898
2971
  event,
2899
2972
  level = "info",
@@ -2914,7 +2987,7 @@ var useHostRuntimeApi = (options, hookName) => {
2914
2987
  );
2915
2988
  const lastObservedStateVersionRef = useRef7(null);
2916
2989
  const emittedInvariantKeysRef = useRef7(/* @__PURE__ */ new Set());
2917
- const emitInvariantOnce = useCallback8(
2990
+ const emitInvariantOnce = useCallback9(
2918
2991
  ({
2919
2992
  code,
2920
2993
  roomId,
@@ -2939,7 +3012,7 @@ var useHostRuntimeApi = (options, hookName) => {
2939
3012
  },
2940
3013
  [emitHostRuntimeEvent]
2941
3014
  );
2942
- const sendState = useCallback8(
3015
+ const sendState = useCallback9(
2943
3016
  (state) => {
2944
3017
  const activeSocket = socket;
2945
3018
  const activeRoomId = parsedRoomIdRef.current;
@@ -2958,7 +3031,7 @@ var useHostRuntimeApi = (options, hookName) => {
2958
3031
  },
2959
3032
  [canEmitAuthoritativeHostState, socket]
2960
3033
  );
2961
- const setRuntimeState = useCallback8(
3034
+ const setRuntimeState = useCallback9(
2962
3035
  (runtimeState) => {
2963
3036
  const activeRoomId = parsedRoomIdRef.current;
2964
3037
  if (store.getState().runtimeState === runtimeState) {
@@ -2971,13 +3044,13 @@ var useHostRuntimeApi = (options, hookName) => {
2971
3044
  },
2972
3045
  [canEmitAuthoritativeHostState, sendState, store]
2973
3046
  );
2974
- const pauseRuntime = useCallback8(() => {
3047
+ const pauseRuntime = useCallback9(() => {
2975
3048
  setRuntimeState("paused");
2976
3049
  }, [setRuntimeState]);
2977
- const resumeRuntime = useCallback8(() => {
3050
+ const resumeRuntime = useCallback9(() => {
2978
3051
  setRuntimeState("playing");
2979
3052
  }, [setRuntimeState]);
2980
- const sendSignal = useCallback8(
3053
+ const sendSignal = useCallback9(
2981
3054
  (type, payload, targetId) => {
2982
3055
  if (!socket || !socket.connected) {
2983
3056
  return;
@@ -2991,7 +3064,7 @@ var useHostRuntimeApi = (options, hookName) => {
2991
3064
  },
2992
3065
  [socket]
2993
3066
  );
2994
- const reconnect = useCallback8(() => {
3067
+ const reconnect = useCallback9(() => {
2995
3068
  socket?.disconnect();
2996
3069
  if (!embeddedHost) {
2997
3070
  disconnectSocket("host");
@@ -3000,7 +3073,7 @@ var useHostRuntimeApi = (options, hookName) => {
3000
3073
  socket.connect();
3001
3074
  }
3002
3075
  }, [socket, embeddedHost, disconnectSocket]);
3003
- const removeController = useCallback8(
3076
+ const removeController = useCallback9(
3004
3077
  async (controllerId) => {
3005
3078
  const activeRoomId = parsedRoomIdRef.current;
3006
3079
  if (!socket || !activeRoomId) {
@@ -3017,7 +3090,7 @@ var useHostRuntimeApi = (options, hookName) => {
3017
3090
  },
3018
3091
  [socket]
3019
3092
  );
3020
- const resetRoom = useCallback8(async () => {
3093
+ const resetRoom = useCallback9(async () => {
3021
3094
  const activeRoomId = parsedRoomIdRef.current;
3022
3095
  if (!socket || !activeRoomId) {
3023
3096
  return {
@@ -3060,7 +3133,7 @@ var useHostRuntimeApi = (options, hookName) => {
3060
3133
  socket,
3061
3134
  store
3062
3135
  ]);
3063
- useEffect7(() => {
3136
+ useEffect8(() => {
3064
3137
  if (embeddedHost?.joinUrl) {
3065
3138
  return;
3066
3139
  }
@@ -3106,16 +3179,16 @@ var useHostRuntimeApi = (options, hookName) => {
3106
3179
  const reconnectRetryTimeoutRef = useRef7(
3107
3180
  null
3108
3181
  );
3109
- const setDevHostTraceId = useCallback8((traceId) => {
3182
+ const setDevHostTraceId = useCallback9((traceId) => {
3110
3183
  updateDevBrowserLogContext({ traceId });
3111
3184
  }, []);
3112
- useEffect7(() => {
3185
+ useEffect8(() => {
3113
3186
  updateDevBrowserLogContext({
3114
3187
  role: "host",
3115
3188
  roomId: parsedRoomId ?? void 0
3116
3189
  });
3117
3190
  }, [parsedRoomId]);
3118
- useEffect7(() => {
3191
+ useEffect8(() => {
3119
3192
  return () => {
3120
3193
  updateDevBrowserLogContext({
3121
3194
  role: void 0,
@@ -3124,13 +3197,13 @@ var useHostRuntimeApi = (options, hookName) => {
3124
3197
  });
3125
3198
  };
3126
3199
  }, []);
3127
- const hostGrantResponseSchema = useMemo5(
3200
+ const hostGrantResponseSchema = useMemo6(
3128
3201
  () => zod.object({
3129
3202
  hostGrant: zod.string().min(1)
3130
3203
  }),
3131
3204
  []
3132
3205
  );
3133
- useEffect7(() => {
3206
+ useEffect8(() => {
3134
3207
  const storeState = store.getState();
3135
3208
  const initialRoomId = parsedRoomIdRef.current;
3136
3209
  storeState.setMode(detectRunMode());
@@ -3604,7 +3677,7 @@ var useHostRuntimeApi = (options, hookName) => {
3604
3677
  emitInvariantOnce,
3605
3678
  hydrateHostRoster
3606
3679
  ]);
3607
- const getInput = useCallback8(
3680
+ const getInput = useCallback9(
3608
3681
  (controllerId) => {
3609
3682
  if (!inputManager) {
3610
3683
  return void 0;
@@ -3613,7 +3686,7 @@ var useHostRuntimeApi = (options, hookName) => {
3613
3686
  },
3614
3687
  [inputManager]
3615
3688
  );
3616
- return useMemo5(
3689
+ return useMemo6(
3617
3690
  () => ({
3618
3691
  roomId: parsedRoomId ?? "",
3619
3692
  joinUrl,
@@ -3652,7 +3725,7 @@ var useHostRuntimeApi = (options, hookName) => {
3652
3725
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
3653
3726
  var HostRuntimeInspectionPublisher = () => {
3654
3727
  const inspection = useHostRuntimeInspectionContract();
3655
- useEffect8(() => {
3728
+ useEffect9(() => {
3656
3729
  if (typeof window === "undefined") {
3657
3730
  return;
3658
3731
  }
@@ -3667,7 +3740,7 @@ var HostRuntimeInspectionPublisher = () => {
3667
3740
  };
3668
3741
  var ControllerRuntimeInspectionPublisher = () => {
3669
3742
  const inspection = useControllerRuntimeInspectionContract();
3670
- useEffect8(() => {
3743
+ useEffect9(() => {
3671
3744
  if (typeof window === "undefined") {
3672
3745
  return;
3673
3746
  }
@@ -3797,7 +3870,7 @@ import {
3797
3870
  RefreshCw,
3798
3871
  RotateCcw
3799
3872
  } from "lucide-react";
3800
- import { Component, useCallback as useCallback9, useEffect as useEffect9, useRef as useRef8, useState as useState5 } from "react";
3873
+ import { Component, useCallback as useCallback10, useEffect as useEffect10, useRef as useRef8, useState as useState6 } from "react";
3801
3874
  import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
3802
3875
  var toError = (value) => {
3803
3876
  if (value instanceof Error) {
@@ -3897,19 +3970,19 @@ var DefaultFallback = ({
3897
3970
  isEmbedded
3898
3971
  }) => {
3899
3972
  const digest = createErrorDigest(error);
3900
- const [isMinimized, setIsMinimized] = useState5(false);
3901
- const [copyState, setCopyState] = useState5(
3973
+ const [isMinimized, setIsMinimized] = useState6(false);
3974
+ const [copyState, setCopyState] = useState6(
3902
3975
  "idle"
3903
3976
  );
3904
3977
  const copyResetTimeoutRef = useRef8(null);
3905
- useEffect9(() => {
3978
+ useEffect10(() => {
3906
3979
  return () => {
3907
3980
  if (copyResetTimeoutRef.current !== null && typeof window !== "undefined") {
3908
3981
  window.clearTimeout(copyResetTimeoutRef.current);
3909
3982
  }
3910
3983
  };
3911
3984
  }, []);
3912
- const scheduleCopyStatusReset = useCallback9(() => {
3985
+ const scheduleCopyStatusReset = useCallback10(() => {
3913
3986
  if (typeof window === "undefined") {
3914
3987
  return;
3915
3988
  }
@@ -3921,7 +3994,7 @@ var DefaultFallback = ({
3921
3994
  copyResetTimeoutRef.current = null;
3922
3995
  }, 1800);
3923
3996
  }, []);
3924
- const handleCopy = useCallback9(async () => {
3997
+ const handleCopy = useCallback10(async () => {
3925
3998
  try {
3926
3999
  await copyTextToClipboard(
3927
4000
  createCopyPayload({
@@ -4421,7 +4494,6 @@ var AirJamErrorBoundary = class extends Component {
4421
4494
  };
4422
4495
 
4423
4496
  // src/runtime/create-air-jam-app.tsx
4424
- import { resolveProjectRuntimeTopology } from "@air-jam/runtime-topology";
4425
4497
  import { jsx as jsx5 } from "react/jsx-runtime";
4426
4498
  var resolveControllerPath = (controllerPath) => {
4427
4499
  const normalized = controllerPath ?? CONTROLLER_PATH;
@@ -4580,7 +4652,7 @@ var resolveAirJamBrowserRouterBasename = () => {
4580
4652
  };
4581
4653
 
4582
4654
  // src/store/create-air-jam-store.ts
4583
- import { useEffect as useEffect10, useMemo as useMemo6, useRef as useRef9 } from "react";
4655
+ import { useEffect as useEffect11, useMemo as useMemo7, useRef as useRef9 } from "react";
4584
4656
  import { create } from "zustand";
4585
4657
  var INTERNAL_ACTION_PREFIX = "_";
4586
4658
  var UNRESOLVED_ACTOR_ID = "unknown";
@@ -5108,11 +5180,11 @@ function createAirJamStore(initializer, options) {
5108
5180
  );
5109
5181
  const blockArcadeShellHostBroadcast = resolvedStoreDomain === AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN && hostArcadeRestore.phase !== "idle";
5110
5182
  const canBroadcastHostState = role === "host" && !!roomId && registeredRoomId === roomId && !blockArcadeShellHostBroadcast;
5111
- const connectedPlayerIds = useMemo6(
5183
+ const connectedPlayerIds = useMemo7(
5112
5184
  () => Array.from(new Set(players.map((player) => player.id))).sort(),
5113
5185
  [players]
5114
5186
  );
5115
- const playerRosterKey = useMemo6(
5187
+ const playerRosterKey = useMemo7(
5116
5188
  () => players.map((player) => player.id).sort().join(","),
5117
5189
  [players]
5118
5190
  );
@@ -5133,7 +5205,7 @@ function createAirJamStore(initializer, options) {
5133
5205
  socket.id ?? "socket",
5134
5206
  role === "controller" ? connectionStatus : "host"
5135
5207
  ].join(":") : null;
5136
- useEffect10(() => {
5208
+ useEffect11(() => {
5137
5209
  if (!runtimeBindingKey || !socket || !roomId || !role) {
5138
5210
  return;
5139
5211
  }
@@ -5168,7 +5240,7 @@ function createAirJamStore(initializer, options) {
5168
5240
  socket?.id,
5169
5241
  resolvedStoreDomain
5170
5242
  ]);
5171
- useEffect10(() => {
5243
+ useEffect11(() => {
5172
5244
  if (!runtimeBindingKey || role !== "host" || !canBroadcastHostState || !roomId) {
5173
5245
  return;
5174
5246
  }
@@ -5199,7 +5271,7 @@ function createAirJamStore(initializer, options) {
5199
5271
  canBroadcastHostState,
5200
5272
  runtimeBindingKey
5201
5273
  ]);
5202
- const dispatchedActions = useMemo6(
5274
+ const dispatchedActions = useMemo7(
5203
5275
  () => createDispatchedActions({ kind: "default" }),
5204
5276
  []
5205
5277
  );
@@ -5235,12 +5307,12 @@ function createAirJamStore(initializer, options) {
5235
5307
  };
5236
5308
  const useHostActionListener = (listener, options2) => {
5237
5309
  const listenerRef = useRef9(listener);
5238
- useEffect10(() => {
5310
+ useEffect11(() => {
5239
5311
  listenerRef.current = listener;
5240
5312
  }, [listener]);
5241
5313
  const includeRejected = options2?.includeRejected ?? false;
5242
5314
  const actionNamesKey = options2?.actionNames?.join("\0") ?? "";
5243
- useEffect10(() => {
5315
+ useEffect11(() => {
5244
5316
  return subscribeHostActions((event) => {
5245
5317
  listenerRef.current(event);
5246
5318
  }, options2);
@@ -5249,7 +5321,7 @@ function createAirJamStore(initializer, options) {
5249
5321
  const useLiveStateRef = () => {
5250
5322
  const latestState = useSyncedStore((state) => state);
5251
5323
  const stateRef = useRef9(latestState);
5252
- useEffect10(() => {
5324
+ useEffect11(() => {
5253
5325
  stateRef.current = latestState;
5254
5326
  }, [latestState]);
5255
5327
  return stateRef;
@@ -5310,6 +5382,7 @@ export {
5310
5382
  useControllerTick,
5311
5383
  useControllerToasts,
5312
5384
  useGetInput,
5385
+ useHostAudioMutePreference,
5313
5386
  useHostRuntimeInspectionContract,
5314
5387
  useHostTick,
5315
5388
  useInheritedPlatformSettings,