@air-jam/sdk 0.9.1 → 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.
- package/dist/arcade/bridge/controller.cjs +1 -1
- package/dist/arcade/bridge/controller.js +2 -2
- package/dist/arcade/bridge/host.cjs +1 -1
- package/dist/arcade/bridge/host.js +2 -2
- package/dist/arcade/bridge/iframe.cjs +1 -1
- package/dist/arcade/bridge/iframe.js +3 -3
- package/dist/arcade/bridge.cjs +1 -1
- package/dist/arcade/bridge.js +5 -5
- package/dist/arcade.cjs +1 -1
- package/dist/arcade.js +5 -5
- package/dist/{chunk-KXAFI5OP.js → chunk-6CMB356F.js} +2 -2
- package/dist/{chunk-FAT2KJ3K.js → chunk-7OTQTT6H.js} +2 -2
- package/dist/{chunk-CABEUV65.js → chunk-CVYR5RJT.js} +2 -2
- package/dist/{chunk-JEHV5C2X.js → chunk-DY67S3LR.js} +2 -2
- package/dist/{chunk-W3YA5BWR.js → chunk-E5PVHEAX.js} +2 -2
- package/dist/{chunk-VKBMZHMQ.js → chunk-KOB73SPD.js} +2 -2
- package/dist/{chunk-7UXSWCZZ.js → chunk-M4DKOI42.js} +2 -2
- package/dist/{chunk-CEJ5RFSG.js → chunk-Q4UALQO4.js} +2 -2
- package/dist/index.cjs +172 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +160 -89
- package/dist/index.js.map +1 -1
- package/dist/preview.js +4 -4
- package/dist/ui.cjs +95 -18
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +11 -1
- package/dist/ui.d.ts +11 -1
- package/dist/ui.js +106 -29
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/components/join-qr-overlay.tsx +115 -31
- package/src/hooks/use-host-audio-mute-preference.ts +99 -0
- package/src/index.ts +4 -0
- /package/dist/{chunk-KXAFI5OP.js.map → chunk-6CMB356F.js.map} +0 -0
- /package/dist/{chunk-FAT2KJ3K.js.map → chunk-7OTQTT6H.js.map} +0 -0
- /package/dist/{chunk-CABEUV65.js.map → chunk-CVYR5RJT.js.map} +0 -0
- /package/dist/{chunk-JEHV5C2X.js.map → chunk-DY67S3LR.js.map} +0 -0
- /package/dist/{chunk-W3YA5BWR.js.map → chunk-E5PVHEAX.js.map} +0 -0
- /package/dist/{chunk-VKBMZHMQ.js.map → chunk-KOB73SPD.js.map} +0 -0
- /package/dist/{chunk-7UXSWCZZ.js.map → chunk-M4DKOI42.js.map} +0 -0
- /package/dist/{chunk-CEJ5RFSG.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-
|
|
5
|
+
} from "./chunk-CVYR5RJT.js";
|
|
6
6
|
import {
|
|
7
7
|
agentAction,
|
|
8
8
|
agentActionInput,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
parseHostBridgeCloseMessage,
|
|
20
20
|
parseHostBridgeEventMessage,
|
|
21
21
|
parseHostBridgeResponseMessage
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-6CMB356F.js";
|
|
23
23
|
import {
|
|
24
24
|
createControllerBridgeCloseMessage,
|
|
25
25
|
createControllerBridgeEmitMessage,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
parseControllerBridgeCloseMessage,
|
|
29
29
|
parseControllerBridgeEventMessage,
|
|
30
30
|
parseControllerBridgeResponseMessage
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-KOB73SPD.js";
|
|
32
32
|
import {
|
|
33
33
|
urlBuilder
|
|
34
34
|
} from "./chunk-YXHH3MQT.js";
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
isPreviewCloseRequestMessage,
|
|
40
40
|
readPreviewControllerDeviceIdFromLocation,
|
|
41
41
|
useAirJamHost
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-E5PVHEAX.js";
|
|
43
43
|
import {
|
|
44
44
|
PlatformSettingsBoundary,
|
|
45
45
|
PlatformSettingsRuntime,
|
|
@@ -50,9 +50,9 @@ import {
|
|
|
50
50
|
usePlatformSettings,
|
|
51
51
|
usePlatformSettingsRuntimeStatus,
|
|
52
52
|
useResolvedPlatformSettingsSnapshot
|
|
53
|
-
} from "./chunk-
|
|
54
|
-
import "./chunk-
|
|
55
|
-
import "./chunk-
|
|
53
|
+
} from "./chunk-Q4UALQO4.js";
|
|
54
|
+
import "./chunk-7OTQTT6H.js";
|
|
55
|
+
import "./chunk-DY67S3LR.js";
|
|
56
56
|
import {
|
|
57
57
|
AirJamProvider,
|
|
58
58
|
RuntimeOwnerRegistryContext,
|
|
@@ -1732,8 +1732,78 @@ var useHostTick = (options) => {
|
|
|
1732
1732
|
}, [enabled, mode, tickIntervalMs, frameDeltaCapMs, frameStepCap]);
|
|
1733
1733
|
};
|
|
1734
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
|
+
|
|
1735
1805
|
// src/hooks/use-input-writer.ts
|
|
1736
|
-
import { useCallback as
|
|
1806
|
+
import { useCallback as useCallback5 } from "react";
|
|
1737
1807
|
|
|
1738
1808
|
// src/utils/is-rpc-serializable.ts
|
|
1739
1809
|
var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
@@ -1780,7 +1850,7 @@ var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
|
1780
1850
|
var useInputWriter = () => {
|
|
1781
1851
|
useAssertSessionScope("controller", "useInputWriter");
|
|
1782
1852
|
const { store, getSocket } = useAirJamContext();
|
|
1783
|
-
return
|
|
1853
|
+
return useCallback5(
|
|
1784
1854
|
(input) => {
|
|
1785
1855
|
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
1786
1856
|
emitAirJamDiagnostic({
|
|
@@ -1866,11 +1936,11 @@ var useRoom = () => {
|
|
|
1866
1936
|
};
|
|
1867
1937
|
|
|
1868
1938
|
// src/hooks/use-send-signal.ts
|
|
1869
|
-
import { useCallback as
|
|
1939
|
+
import { useCallback as useCallback6 } from "react";
|
|
1870
1940
|
var useSendSignal = () => {
|
|
1871
1941
|
useAssertSessionScope("host", "useSendSignal");
|
|
1872
1942
|
const { getSocket } = useAirJamContext();
|
|
1873
|
-
const sendSignal =
|
|
1943
|
+
const sendSignal = useCallback6(
|
|
1874
1944
|
(type, payload, targetId) => {
|
|
1875
1945
|
const socket = getHostRealtimeClient((role) => getSocket(role));
|
|
1876
1946
|
if (!socket || !socket.connected) {
|
|
@@ -1942,10 +2012,10 @@ var useHostRuntimeInspectionContract = () => createHostRuntimeInspectionContract
|
|
|
1942
2012
|
var useControllerRuntimeInspectionContract = () => createControllerRuntimeInspectionContract(useAirJamController());
|
|
1943
2013
|
|
|
1944
2014
|
// src/runtime/session-runtimes.tsx
|
|
1945
|
-
import { useEffect as
|
|
2015
|
+
import { useEffect as useEffect9 } from "react";
|
|
1946
2016
|
|
|
1947
2017
|
// src/context/session-providers.tsx
|
|
1948
|
-
import { useCallback as
|
|
2018
|
+
import { useCallback as useCallback7, useRef as useRef5 } from "react";
|
|
1949
2019
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1950
2020
|
var createScopedSessionProvider = (scope) => {
|
|
1951
2021
|
const ScopedSessionProvider = ({
|
|
@@ -1953,7 +2023,7 @@ var createScopedSessionProvider = (scope) => {
|
|
|
1953
2023
|
...providerProps
|
|
1954
2024
|
}) => {
|
|
1955
2025
|
const runtimeOwnersRef = useRef5(/* @__PURE__ */ new Map());
|
|
1956
|
-
const claimOwner =
|
|
2026
|
+
const claimOwner = useCallback7(
|
|
1957
2027
|
(kind, token, hookName) => {
|
|
1958
2028
|
const existing = runtimeOwnersRef.current.get(kind);
|
|
1959
2029
|
if (existing && existing.token !== token) {
|
|
@@ -1986,7 +2056,7 @@ var HostSessionProvider = createScopedSessionProvider("host");
|
|
|
1986
2056
|
var ControllerSessionProvider = createScopedSessionProvider("controller");
|
|
1987
2057
|
|
|
1988
2058
|
// src/hooks/internal/use-controller-runtime-api.ts
|
|
1989
|
-
import { useCallback as
|
|
2059
|
+
import { useCallback as useCallback8, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef6, useState as useState4 } from "react";
|
|
1990
2060
|
import { useStore as useStore5 } from "zustand";
|
|
1991
2061
|
|
|
1992
2062
|
// src/runtime/controller-identity.ts
|
|
@@ -2159,27 +2229,27 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2159
2229
|
const { store, getSocket, disconnectSocket } = useAirJamContext();
|
|
2160
2230
|
const nicknameRef = useRef6(options.nickname ?? "");
|
|
2161
2231
|
const avatarIdRef = useRef6(options.avatarId ?? "");
|
|
2162
|
-
|
|
2232
|
+
useEffect7(() => {
|
|
2163
2233
|
nicknameRef.current = options.nickname ?? "";
|
|
2164
2234
|
}, [options.nickname]);
|
|
2165
|
-
|
|
2235
|
+
useEffect7(() => {
|
|
2166
2236
|
avatarIdRef.current = options.avatarId ?? "";
|
|
2167
2237
|
}, [options.avatarId]);
|
|
2168
|
-
const embeddedController =
|
|
2238
|
+
const embeddedController = useMemo5(
|
|
2169
2239
|
() => readEmbeddedControllerChildSession(),
|
|
2170
2240
|
[]
|
|
2171
2241
|
);
|
|
2172
|
-
const urlRoomId =
|
|
2173
|
-
const locationCapabilityToken =
|
|
2242
|
+
const urlRoomId = useMemo5(() => getRoomFromLocation(), []);
|
|
2243
|
+
const locationCapabilityToken = useMemo5(
|
|
2174
2244
|
() => getControllerCapabilityTokenFromLocation(),
|
|
2175
2245
|
[]
|
|
2176
2246
|
);
|
|
2177
2247
|
const capabilityToken = options.capabilityToken === void 0 ? locationCapabilityToken : options.capabilityToken;
|
|
2178
|
-
const previewDeviceId =
|
|
2248
|
+
const previewDeviceId = useMemo5(
|
|
2179
2249
|
() => readPreviewControllerDeviceIdFromLocation(),
|
|
2180
2250
|
[]
|
|
2181
2251
|
);
|
|
2182
|
-
const joinSource =
|
|
2252
|
+
const joinSource = useMemo5(
|
|
2183
2253
|
() => resolveControllerJoinSource({
|
|
2184
2254
|
embeddedRoomId: embeddedController?.roomId,
|
|
2185
2255
|
optionRoomId: options.roomId ?? null,
|
|
@@ -2187,7 +2257,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2187
2257
|
}),
|
|
2188
2258
|
[embeddedController?.roomId, options.roomId, urlRoomId]
|
|
2189
2259
|
);
|
|
2190
|
-
const parsedRoomId =
|
|
2260
|
+
const parsedRoomId = useMemo5(() => {
|
|
2191
2261
|
const code = embeddedController?.roomId ?? options.roomId ?? urlRoomId;
|
|
2192
2262
|
if (!code) return null;
|
|
2193
2263
|
try {
|
|
@@ -2196,7 +2266,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2196
2266
|
return null;
|
|
2197
2267
|
}
|
|
2198
2268
|
}, [options.roomId, embeddedController, urlRoomId]);
|
|
2199
|
-
const deviceId =
|
|
2269
|
+
const deviceId = useMemo5(() => {
|
|
2200
2270
|
if (embeddedController) {
|
|
2201
2271
|
return null;
|
|
2202
2272
|
}
|
|
@@ -2205,7 +2275,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2205
2275
|
}
|
|
2206
2276
|
return getOrCreateControllerDeviceId();
|
|
2207
2277
|
}, [embeddedController, previewDeviceId]);
|
|
2208
|
-
const controllerId =
|
|
2278
|
+
const controllerId = useMemo5(() => {
|
|
2209
2279
|
if (embeddedController?.controllerId) {
|
|
2210
2280
|
return embeddedController.controllerId;
|
|
2211
2281
|
}
|
|
@@ -2228,11 +2298,11 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2228
2298
|
const onStateRef = useRef6(
|
|
2229
2299
|
options.onState
|
|
2230
2300
|
);
|
|
2231
|
-
|
|
2301
|
+
useEffect7(() => {
|
|
2232
2302
|
onStateRef.current = options.onState;
|
|
2233
2303
|
}, [options.onState]);
|
|
2234
2304
|
const activeControllerId = useStore5(store, (state) => state.controllerId);
|
|
2235
|
-
|
|
2305
|
+
useEffect7(() => {
|
|
2236
2306
|
updateDevBrowserLogContext({
|
|
2237
2307
|
role: "controller",
|
|
2238
2308
|
traceId: void 0,
|
|
@@ -2240,7 +2310,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2240
2310
|
controllerId: activeControllerId ?? controllerId ?? void 0
|
|
2241
2311
|
});
|
|
2242
2312
|
}, [activeControllerId, controllerId, parsedRoomId]);
|
|
2243
|
-
|
|
2313
|
+
useEffect7(() => {
|
|
2244
2314
|
return () => {
|
|
2245
2315
|
updateDevBrowserLogContext({
|
|
2246
2316
|
role: void 0,
|
|
@@ -2249,9 +2319,9 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2249
2319
|
});
|
|
2250
2320
|
};
|
|
2251
2321
|
}, []);
|
|
2252
|
-
const [reconnectKey, setReconnectKey] =
|
|
2322
|
+
const [reconnectKey, setReconnectKey] = useState4(0);
|
|
2253
2323
|
const leaveIssuedRef = useRef6(false);
|
|
2254
|
-
const emitControllerRuntimeEvent =
|
|
2324
|
+
const emitControllerRuntimeEvent = useCallback8(
|
|
2255
2325
|
({
|
|
2256
2326
|
event,
|
|
2257
2327
|
level = "info",
|
|
@@ -2273,7 +2343,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2273
2343
|
);
|
|
2274
2344
|
const lastObservedStateVersionRef = useRef6(null);
|
|
2275
2345
|
const emittedInvariantKeysRef = useRef6(/* @__PURE__ */ new Set());
|
|
2276
|
-
const emitInvariantOnce =
|
|
2346
|
+
const emitInvariantOnce = useCallback8(
|
|
2277
2347
|
({
|
|
2278
2348
|
code,
|
|
2279
2349
|
roomId,
|
|
@@ -2298,11 +2368,11 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2298
2368
|
},
|
|
2299
2369
|
[emitControllerRuntimeEvent]
|
|
2300
2370
|
);
|
|
2301
|
-
const socket =
|
|
2371
|
+
const socket = useMemo5(
|
|
2302
2372
|
() => parsedRoomId ? getControllerRealtimeClient((role) => getSocket(role)) : null,
|
|
2303
2373
|
[parsedRoomId, getSocket]
|
|
2304
2374
|
);
|
|
2305
|
-
const reconnect =
|
|
2375
|
+
const reconnect = useCallback8(() => {
|
|
2306
2376
|
if (!parsedRoomId) return;
|
|
2307
2377
|
socket?.disconnect();
|
|
2308
2378
|
if (!embeddedController) {
|
|
@@ -2310,7 +2380,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2310
2380
|
}
|
|
2311
2381
|
setReconnectKey((prev) => prev + 1);
|
|
2312
2382
|
}, [parsedRoomId, disconnectSocket, socket, embeddedController]);
|
|
2313
|
-
const leave =
|
|
2383
|
+
const leave = useCallback8(async () => {
|
|
2314
2384
|
const storeState = store.getState();
|
|
2315
2385
|
const activeControllerId2 = storeState.controllerId;
|
|
2316
2386
|
if (!socket || !parsedRoomId || !activeControllerId2) {
|
|
@@ -2358,7 +2428,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2358
2428
|
);
|
|
2359
2429
|
});
|
|
2360
2430
|
}, [embeddedController, parsedRoomId, socket, store]);
|
|
2361
|
-
|
|
2431
|
+
useEffect7(() => {
|
|
2362
2432
|
if (!socket) return;
|
|
2363
2433
|
const handleSignal = (signal) => {
|
|
2364
2434
|
if (signal.type !== "HAPTIC") return;
|
|
@@ -2394,7 +2464,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2394
2464
|
socket.off("server:signal", handleSignal);
|
|
2395
2465
|
};
|
|
2396
2466
|
}, [socket]);
|
|
2397
|
-
|
|
2467
|
+
useEffect7(() => {
|
|
2398
2468
|
if (typeof window === "undefined" || !previewDeviceId || embeddedController || !socket) {
|
|
2399
2469
|
return;
|
|
2400
2470
|
}
|
|
@@ -2422,7 +2492,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2422
2492
|
window.removeEventListener("message", handleMessage);
|
|
2423
2493
|
};
|
|
2424
2494
|
}, [disconnectSocket, embeddedController, leave, previewDeviceId, socket]);
|
|
2425
|
-
|
|
2495
|
+
useEffect7(() => {
|
|
2426
2496
|
if (!previewDeviceId || !parsedRoomId || embeddedController || !socket) {
|
|
2427
2497
|
return;
|
|
2428
2498
|
}
|
|
@@ -2443,7 +2513,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2443
2513
|
);
|
|
2444
2514
|
};
|
|
2445
2515
|
}, [embeddedController, parsedRoomId, previewDeviceId, socket, store]);
|
|
2446
|
-
|
|
2516
|
+
useEffect7(() => {
|
|
2447
2517
|
const storeState = store.getState();
|
|
2448
2518
|
storeState.setMode(detectRunMode());
|
|
2449
2519
|
storeState.setRole("controller");
|
|
@@ -2735,13 +2805,13 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2735
2805
|
capabilityToken,
|
|
2736
2806
|
emitInvariantOnce
|
|
2737
2807
|
]);
|
|
2738
|
-
const setNickname =
|
|
2808
|
+
const setNickname = useCallback8((value) => {
|
|
2739
2809
|
nicknameRef.current = value;
|
|
2740
2810
|
}, []);
|
|
2741
|
-
const setAvatarId =
|
|
2811
|
+
const setAvatarId = useCallback8((value) => {
|
|
2742
2812
|
avatarIdRef.current = value;
|
|
2743
2813
|
}, []);
|
|
2744
|
-
const updatePlayerProfile =
|
|
2814
|
+
const updatePlayerProfile = useCallback8(
|
|
2745
2815
|
(patch) => {
|
|
2746
2816
|
const parsedPatch = playerProfilePatchSchema.safeParse(patch);
|
|
2747
2817
|
if (!parsedPatch.success) {
|
|
@@ -2778,7 +2848,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2778
2848
|
},
|
|
2779
2849
|
[parsedRoomId, socket, store, embeddedController]
|
|
2780
2850
|
);
|
|
2781
|
-
const sendSystemCommand =
|
|
2851
|
+
const sendSystemCommand = useCallback8(
|
|
2782
2852
|
(command) => {
|
|
2783
2853
|
const storeState = store.getState();
|
|
2784
2854
|
if (!parsedRoomId || !storeState.controllerId || !socket) return;
|
|
@@ -2793,7 +2863,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2793
2863
|
},
|
|
2794
2864
|
[parsedRoomId, socket, store]
|
|
2795
2865
|
);
|
|
2796
|
-
return
|
|
2866
|
+
return useMemo5(
|
|
2797
2867
|
() => ({
|
|
2798
2868
|
sendSystemCommand,
|
|
2799
2869
|
setNickname,
|
|
@@ -2816,7 +2886,7 @@ var useControllerRuntimeApi = (options, hookName) => {
|
|
|
2816
2886
|
};
|
|
2817
2887
|
|
|
2818
2888
|
// src/hooks/internal/use-host-runtime-api.ts
|
|
2819
|
-
import { useCallback as
|
|
2889
|
+
import { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo6, useRef as useRef7, useState as useState5 } from "react";
|
|
2820
2890
|
import { z as zod } from "zod";
|
|
2821
2891
|
import { useStore as useStore6 } from "zustand";
|
|
2822
2892
|
var HOST_BOOTSTRAP_TIMEOUT_MESSAGE = "Host bootstrap timed out. The deployed Air Jam server may be out of sync with this client.";
|
|
@@ -2824,10 +2894,10 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2824
2894
|
useAssertSessionScope("host", hookName);
|
|
2825
2895
|
useClaimSessionRuntimeOwner("host-runtime", hookName);
|
|
2826
2896
|
const { config, store, getSocket, disconnectSocket, inputManager } = useAirJamContext();
|
|
2827
|
-
const embeddedHost =
|
|
2897
|
+
const embeddedHost = useMemo6(() => readEmbeddedHostChildSession(), []);
|
|
2828
2898
|
const shouldConnect = true;
|
|
2829
2899
|
const storeRoomId = useStore6(store, (s) => s.roomId);
|
|
2830
|
-
const parsedRoomId =
|
|
2900
|
+
const parsedRoomId = useMemo6(() => {
|
|
2831
2901
|
if (embeddedHost) {
|
|
2832
2902
|
return embeddedHost.roomId;
|
|
2833
2903
|
}
|
|
@@ -2847,12 +2917,12 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2847
2917
|
}
|
|
2848
2918
|
return null;
|
|
2849
2919
|
}, [options.roomId, storeRoomId, embeddedHost]);
|
|
2850
|
-
const [controllerCapability, setControllerCapability] =
|
|
2851
|
-
const joinUrlBuildKey =
|
|
2920
|
+
const [controllerCapability, setControllerCapability] = useState5(null);
|
|
2921
|
+
const joinUrlBuildKey = useMemo6(
|
|
2852
2922
|
() => parsedRoomId ? `${parsedRoomId}\0${config.publicHost ?? ""}\0${controllerCapability?.token ?? ""}` : null,
|
|
2853
2923
|
[config.publicHost, controllerCapability?.token, parsedRoomId]
|
|
2854
2924
|
);
|
|
2855
|
-
const [computedJoinUrl, setComputedJoinUrl] =
|
|
2925
|
+
const [computedJoinUrl, setComputedJoinUrl] = useState5({
|
|
2856
2926
|
key: null,
|
|
2857
2927
|
url: "",
|
|
2858
2928
|
error: false
|
|
@@ -2860,19 +2930,19 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2860
2930
|
const onPlayerJoinRef = useRef7(options.onPlayerJoin);
|
|
2861
2931
|
const onPlayerLeaveRef = useRef7(options.onPlayerLeave);
|
|
2862
2932
|
const parsedRoomIdRef = useRef7(parsedRoomId);
|
|
2863
|
-
|
|
2933
|
+
useEffect8(() => {
|
|
2864
2934
|
onPlayerJoinRef.current = options.onPlayerJoin;
|
|
2865
2935
|
onPlayerLeaveRef.current = options.onPlayerLeave;
|
|
2866
2936
|
}, [options.onPlayerJoin, options.onPlayerLeave]);
|
|
2867
|
-
|
|
2937
|
+
useEffect8(() => {
|
|
2868
2938
|
parsedRoomIdRef.current = parsedRoomId;
|
|
2869
2939
|
}, [parsedRoomId]);
|
|
2870
|
-
const socket =
|
|
2940
|
+
const socket = useMemo6(
|
|
2871
2941
|
() => shouldConnect ? getHostRealtimeClient((role) => getSocket(role)) : null,
|
|
2872
2942
|
[shouldConnect, getSocket]
|
|
2873
2943
|
);
|
|
2874
2944
|
const setRegisteredRoomId = useStore6(store, (s) => s.setRegisteredRoomId);
|
|
2875
|
-
const hydrateHostRoster =
|
|
2945
|
+
const hydrateHostRoster = useCallback9(
|
|
2876
2946
|
(players, controllers) => {
|
|
2877
2947
|
const latestState = store.getState();
|
|
2878
2948
|
latestState.resetPlayers();
|
|
@@ -2886,7 +2956,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2886
2956
|
},
|
|
2887
2957
|
[store]
|
|
2888
2958
|
);
|
|
2889
|
-
const canEmitAuthoritativeHostState =
|
|
2959
|
+
const canEmitAuthoritativeHostState = useCallback9(
|
|
2890
2960
|
(roomId) => {
|
|
2891
2961
|
if (!socket || !socket.connected || !roomId) {
|
|
2892
2962
|
return false;
|
|
@@ -2896,7 +2966,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2896
2966
|
},
|
|
2897
2967
|
[socket, store]
|
|
2898
2968
|
);
|
|
2899
|
-
const emitHostRuntimeEvent =
|
|
2969
|
+
const emitHostRuntimeEvent = useCallback9(
|
|
2900
2970
|
({
|
|
2901
2971
|
event,
|
|
2902
2972
|
level = "info",
|
|
@@ -2917,7 +2987,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2917
2987
|
);
|
|
2918
2988
|
const lastObservedStateVersionRef = useRef7(null);
|
|
2919
2989
|
const emittedInvariantKeysRef = useRef7(/* @__PURE__ */ new Set());
|
|
2920
|
-
const emitInvariantOnce =
|
|
2990
|
+
const emitInvariantOnce = useCallback9(
|
|
2921
2991
|
({
|
|
2922
2992
|
code,
|
|
2923
2993
|
roomId,
|
|
@@ -2942,7 +3012,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2942
3012
|
},
|
|
2943
3013
|
[emitHostRuntimeEvent]
|
|
2944
3014
|
);
|
|
2945
|
-
const sendState =
|
|
3015
|
+
const sendState = useCallback9(
|
|
2946
3016
|
(state) => {
|
|
2947
3017
|
const activeSocket = socket;
|
|
2948
3018
|
const activeRoomId = parsedRoomIdRef.current;
|
|
@@ -2961,7 +3031,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2961
3031
|
},
|
|
2962
3032
|
[canEmitAuthoritativeHostState, socket]
|
|
2963
3033
|
);
|
|
2964
|
-
const setRuntimeState =
|
|
3034
|
+
const setRuntimeState = useCallback9(
|
|
2965
3035
|
(runtimeState) => {
|
|
2966
3036
|
const activeRoomId = parsedRoomIdRef.current;
|
|
2967
3037
|
if (store.getState().runtimeState === runtimeState) {
|
|
@@ -2974,13 +3044,13 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2974
3044
|
},
|
|
2975
3045
|
[canEmitAuthoritativeHostState, sendState, store]
|
|
2976
3046
|
);
|
|
2977
|
-
const pauseRuntime =
|
|
3047
|
+
const pauseRuntime = useCallback9(() => {
|
|
2978
3048
|
setRuntimeState("paused");
|
|
2979
3049
|
}, [setRuntimeState]);
|
|
2980
|
-
const resumeRuntime =
|
|
3050
|
+
const resumeRuntime = useCallback9(() => {
|
|
2981
3051
|
setRuntimeState("playing");
|
|
2982
3052
|
}, [setRuntimeState]);
|
|
2983
|
-
const sendSignal =
|
|
3053
|
+
const sendSignal = useCallback9(
|
|
2984
3054
|
(type, payload, targetId) => {
|
|
2985
3055
|
if (!socket || !socket.connected) {
|
|
2986
3056
|
return;
|
|
@@ -2994,7 +3064,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
2994
3064
|
},
|
|
2995
3065
|
[socket]
|
|
2996
3066
|
);
|
|
2997
|
-
const reconnect =
|
|
3067
|
+
const reconnect = useCallback9(() => {
|
|
2998
3068
|
socket?.disconnect();
|
|
2999
3069
|
if (!embeddedHost) {
|
|
3000
3070
|
disconnectSocket("host");
|
|
@@ -3003,7 +3073,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3003
3073
|
socket.connect();
|
|
3004
3074
|
}
|
|
3005
3075
|
}, [socket, embeddedHost, disconnectSocket]);
|
|
3006
|
-
const removeController =
|
|
3076
|
+
const removeController = useCallback9(
|
|
3007
3077
|
async (controllerId) => {
|
|
3008
3078
|
const activeRoomId = parsedRoomIdRef.current;
|
|
3009
3079
|
if (!socket || !activeRoomId) {
|
|
@@ -3020,7 +3090,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3020
3090
|
},
|
|
3021
3091
|
[socket]
|
|
3022
3092
|
);
|
|
3023
|
-
const resetRoom =
|
|
3093
|
+
const resetRoom = useCallback9(async () => {
|
|
3024
3094
|
const activeRoomId = parsedRoomIdRef.current;
|
|
3025
3095
|
if (!socket || !activeRoomId) {
|
|
3026
3096
|
return {
|
|
@@ -3063,7 +3133,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3063
3133
|
socket,
|
|
3064
3134
|
store
|
|
3065
3135
|
]);
|
|
3066
|
-
|
|
3136
|
+
useEffect8(() => {
|
|
3067
3137
|
if (embeddedHost?.joinUrl) {
|
|
3068
3138
|
return;
|
|
3069
3139
|
}
|
|
@@ -3109,16 +3179,16 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3109
3179
|
const reconnectRetryTimeoutRef = useRef7(
|
|
3110
3180
|
null
|
|
3111
3181
|
);
|
|
3112
|
-
const setDevHostTraceId =
|
|
3182
|
+
const setDevHostTraceId = useCallback9((traceId) => {
|
|
3113
3183
|
updateDevBrowserLogContext({ traceId });
|
|
3114
3184
|
}, []);
|
|
3115
|
-
|
|
3185
|
+
useEffect8(() => {
|
|
3116
3186
|
updateDevBrowserLogContext({
|
|
3117
3187
|
role: "host",
|
|
3118
3188
|
roomId: parsedRoomId ?? void 0
|
|
3119
3189
|
});
|
|
3120
3190
|
}, [parsedRoomId]);
|
|
3121
|
-
|
|
3191
|
+
useEffect8(() => {
|
|
3122
3192
|
return () => {
|
|
3123
3193
|
updateDevBrowserLogContext({
|
|
3124
3194
|
role: void 0,
|
|
@@ -3127,13 +3197,13 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3127
3197
|
});
|
|
3128
3198
|
};
|
|
3129
3199
|
}, []);
|
|
3130
|
-
const hostGrantResponseSchema =
|
|
3200
|
+
const hostGrantResponseSchema = useMemo6(
|
|
3131
3201
|
() => zod.object({
|
|
3132
3202
|
hostGrant: zod.string().min(1)
|
|
3133
3203
|
}),
|
|
3134
3204
|
[]
|
|
3135
3205
|
);
|
|
3136
|
-
|
|
3206
|
+
useEffect8(() => {
|
|
3137
3207
|
const storeState = store.getState();
|
|
3138
3208
|
const initialRoomId = parsedRoomIdRef.current;
|
|
3139
3209
|
storeState.setMode(detectRunMode());
|
|
@@ -3607,7 +3677,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3607
3677
|
emitInvariantOnce,
|
|
3608
3678
|
hydrateHostRoster
|
|
3609
3679
|
]);
|
|
3610
|
-
const getInput =
|
|
3680
|
+
const getInput = useCallback9(
|
|
3611
3681
|
(controllerId) => {
|
|
3612
3682
|
if (!inputManager) {
|
|
3613
3683
|
return void 0;
|
|
@@ -3616,7 +3686,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3616
3686
|
},
|
|
3617
3687
|
[inputManager]
|
|
3618
3688
|
);
|
|
3619
|
-
return
|
|
3689
|
+
return useMemo6(
|
|
3620
3690
|
() => ({
|
|
3621
3691
|
roomId: parsedRoomId ?? "",
|
|
3622
3692
|
joinUrl,
|
|
@@ -3655,7 +3725,7 @@ var useHostRuntimeApi = (options, hookName) => {
|
|
|
3655
3725
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
3656
3726
|
var HostRuntimeInspectionPublisher = () => {
|
|
3657
3727
|
const inspection = useHostRuntimeInspectionContract();
|
|
3658
|
-
|
|
3728
|
+
useEffect9(() => {
|
|
3659
3729
|
if (typeof window === "undefined") {
|
|
3660
3730
|
return;
|
|
3661
3731
|
}
|
|
@@ -3670,7 +3740,7 @@ var HostRuntimeInspectionPublisher = () => {
|
|
|
3670
3740
|
};
|
|
3671
3741
|
var ControllerRuntimeInspectionPublisher = () => {
|
|
3672
3742
|
const inspection = useControllerRuntimeInspectionContract();
|
|
3673
|
-
|
|
3743
|
+
useEffect9(() => {
|
|
3674
3744
|
if (typeof window === "undefined") {
|
|
3675
3745
|
return;
|
|
3676
3746
|
}
|
|
@@ -3800,7 +3870,7 @@ import {
|
|
|
3800
3870
|
RefreshCw,
|
|
3801
3871
|
RotateCcw
|
|
3802
3872
|
} from "lucide-react";
|
|
3803
|
-
import { Component, useCallback as
|
|
3873
|
+
import { Component, useCallback as useCallback10, useEffect as useEffect10, useRef as useRef8, useState as useState6 } from "react";
|
|
3804
3874
|
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
3805
3875
|
var toError = (value) => {
|
|
3806
3876
|
if (value instanceof Error) {
|
|
@@ -3900,19 +3970,19 @@ var DefaultFallback = ({
|
|
|
3900
3970
|
isEmbedded
|
|
3901
3971
|
}) => {
|
|
3902
3972
|
const digest = createErrorDigest(error);
|
|
3903
|
-
const [isMinimized, setIsMinimized] =
|
|
3904
|
-
const [copyState, setCopyState] =
|
|
3973
|
+
const [isMinimized, setIsMinimized] = useState6(false);
|
|
3974
|
+
const [copyState, setCopyState] = useState6(
|
|
3905
3975
|
"idle"
|
|
3906
3976
|
);
|
|
3907
3977
|
const copyResetTimeoutRef = useRef8(null);
|
|
3908
|
-
|
|
3978
|
+
useEffect10(() => {
|
|
3909
3979
|
return () => {
|
|
3910
3980
|
if (copyResetTimeoutRef.current !== null && typeof window !== "undefined") {
|
|
3911
3981
|
window.clearTimeout(copyResetTimeoutRef.current);
|
|
3912
3982
|
}
|
|
3913
3983
|
};
|
|
3914
3984
|
}, []);
|
|
3915
|
-
const scheduleCopyStatusReset =
|
|
3985
|
+
const scheduleCopyStatusReset = useCallback10(() => {
|
|
3916
3986
|
if (typeof window === "undefined") {
|
|
3917
3987
|
return;
|
|
3918
3988
|
}
|
|
@@ -3924,7 +3994,7 @@ var DefaultFallback = ({
|
|
|
3924
3994
|
copyResetTimeoutRef.current = null;
|
|
3925
3995
|
}, 1800);
|
|
3926
3996
|
}, []);
|
|
3927
|
-
const handleCopy =
|
|
3997
|
+
const handleCopy = useCallback10(async () => {
|
|
3928
3998
|
try {
|
|
3929
3999
|
await copyTextToClipboard(
|
|
3930
4000
|
createCopyPayload({
|
|
@@ -4582,7 +4652,7 @@ var resolveAirJamBrowserRouterBasename = () => {
|
|
|
4582
4652
|
};
|
|
4583
4653
|
|
|
4584
4654
|
// src/store/create-air-jam-store.ts
|
|
4585
|
-
import { useEffect as
|
|
4655
|
+
import { useEffect as useEffect11, useMemo as useMemo7, useRef as useRef9 } from "react";
|
|
4586
4656
|
import { create } from "zustand";
|
|
4587
4657
|
var INTERNAL_ACTION_PREFIX = "_";
|
|
4588
4658
|
var UNRESOLVED_ACTOR_ID = "unknown";
|
|
@@ -5110,11 +5180,11 @@ function createAirJamStore(initializer, options) {
|
|
|
5110
5180
|
);
|
|
5111
5181
|
const blockArcadeShellHostBroadcast = resolvedStoreDomain === AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN && hostArcadeRestore.phase !== "idle";
|
|
5112
5182
|
const canBroadcastHostState = role === "host" && !!roomId && registeredRoomId === roomId && !blockArcadeShellHostBroadcast;
|
|
5113
|
-
const connectedPlayerIds =
|
|
5183
|
+
const connectedPlayerIds = useMemo7(
|
|
5114
5184
|
() => Array.from(new Set(players.map((player) => player.id))).sort(),
|
|
5115
5185
|
[players]
|
|
5116
5186
|
);
|
|
5117
|
-
const playerRosterKey =
|
|
5187
|
+
const playerRosterKey = useMemo7(
|
|
5118
5188
|
() => players.map((player) => player.id).sort().join(","),
|
|
5119
5189
|
[players]
|
|
5120
5190
|
);
|
|
@@ -5135,7 +5205,7 @@ function createAirJamStore(initializer, options) {
|
|
|
5135
5205
|
socket.id ?? "socket",
|
|
5136
5206
|
role === "controller" ? connectionStatus : "host"
|
|
5137
5207
|
].join(":") : null;
|
|
5138
|
-
|
|
5208
|
+
useEffect11(() => {
|
|
5139
5209
|
if (!runtimeBindingKey || !socket || !roomId || !role) {
|
|
5140
5210
|
return;
|
|
5141
5211
|
}
|
|
@@ -5170,7 +5240,7 @@ function createAirJamStore(initializer, options) {
|
|
|
5170
5240
|
socket?.id,
|
|
5171
5241
|
resolvedStoreDomain
|
|
5172
5242
|
]);
|
|
5173
|
-
|
|
5243
|
+
useEffect11(() => {
|
|
5174
5244
|
if (!runtimeBindingKey || role !== "host" || !canBroadcastHostState || !roomId) {
|
|
5175
5245
|
return;
|
|
5176
5246
|
}
|
|
@@ -5201,7 +5271,7 @@ function createAirJamStore(initializer, options) {
|
|
|
5201
5271
|
canBroadcastHostState,
|
|
5202
5272
|
runtimeBindingKey
|
|
5203
5273
|
]);
|
|
5204
|
-
const dispatchedActions =
|
|
5274
|
+
const dispatchedActions = useMemo7(
|
|
5205
5275
|
() => createDispatchedActions({ kind: "default" }),
|
|
5206
5276
|
[]
|
|
5207
5277
|
);
|
|
@@ -5237,12 +5307,12 @@ function createAirJamStore(initializer, options) {
|
|
|
5237
5307
|
};
|
|
5238
5308
|
const useHostActionListener = (listener, options2) => {
|
|
5239
5309
|
const listenerRef = useRef9(listener);
|
|
5240
|
-
|
|
5310
|
+
useEffect11(() => {
|
|
5241
5311
|
listenerRef.current = listener;
|
|
5242
5312
|
}, [listener]);
|
|
5243
5313
|
const includeRejected = options2?.includeRejected ?? false;
|
|
5244
5314
|
const actionNamesKey = options2?.actionNames?.join("\0") ?? "";
|
|
5245
|
-
|
|
5315
|
+
useEffect11(() => {
|
|
5246
5316
|
return subscribeHostActions((event) => {
|
|
5247
5317
|
listenerRef.current(event);
|
|
5248
5318
|
}, options2);
|
|
@@ -5251,7 +5321,7 @@ function createAirJamStore(initializer, options) {
|
|
|
5251
5321
|
const useLiveStateRef = () => {
|
|
5252
5322
|
const latestState = useSyncedStore((state) => state);
|
|
5253
5323
|
const stateRef = useRef9(latestState);
|
|
5254
|
-
|
|
5324
|
+
useEffect11(() => {
|
|
5255
5325
|
stateRef.current = latestState;
|
|
5256
5326
|
}, [latestState]);
|
|
5257
5327
|
return stateRef;
|
|
@@ -5312,6 +5382,7 @@ export {
|
|
|
5312
5382
|
useControllerTick,
|
|
5313
5383
|
useControllerToasts,
|
|
5314
5384
|
useGetInput,
|
|
5385
|
+
useHostAudioMutePreference,
|
|
5315
5386
|
useHostRuntimeInspectionContract,
|
|
5316
5387
|
useHostTick,
|
|
5317
5388
|
useInheritedPlatformSettings,
|