@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.
Files changed (43) 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 +3 -3
  7. package/dist/arcade/bridge.cjs +1 -1
  8. package/dist/arcade/bridge.js +5 -5
  9. package/dist/arcade.cjs +1 -1
  10. package/dist/arcade.js +5 -5
  11. package/dist/{chunk-KXAFI5OP.js → chunk-6CMB356F.js} +2 -2
  12. package/dist/{chunk-FAT2KJ3K.js → chunk-7OTQTT6H.js} +2 -2
  13. package/dist/{chunk-CABEUV65.js → chunk-CVYR5RJT.js} +2 -2
  14. package/dist/{chunk-JEHV5C2X.js → chunk-DY67S3LR.js} +2 -2
  15. package/dist/{chunk-W3YA5BWR.js → chunk-E5PVHEAX.js} +2 -2
  16. package/dist/{chunk-VKBMZHMQ.js → chunk-KOB73SPD.js} +2 -2
  17. package/dist/{chunk-7UXSWCZZ.js → chunk-M4DKOI42.js} +2 -2
  18. package/dist/{chunk-CEJ5RFSG.js → chunk-Q4UALQO4.js} +2 -2
  19. package/dist/index.cjs +172 -100
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +8 -1
  22. package/dist/index.d.ts +8 -1
  23. package/dist/index.js +160 -89
  24. package/dist/index.js.map +1 -1
  25. package/dist/preview.js +4 -4
  26. package/dist/ui.cjs +95 -18
  27. package/dist/ui.cjs.map +1 -1
  28. package/dist/ui.d.cts +11 -1
  29. package/dist/ui.d.ts +11 -1
  30. package/dist/ui.js +106 -29
  31. package/dist/ui.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/components/join-qr-overlay.tsx +115 -31
  34. package/src/hooks/use-host-audio-mute-preference.ts +99 -0
  35. package/src/index.ts +4 -0
  36. /package/dist/{chunk-KXAFI5OP.js.map → chunk-6CMB356F.js.map} +0 -0
  37. /package/dist/{chunk-FAT2KJ3K.js.map → chunk-7OTQTT6H.js.map} +0 -0
  38. /package/dist/{chunk-CABEUV65.js.map → chunk-CVYR5RJT.js.map} +0 -0
  39. /package/dist/{chunk-JEHV5C2X.js.map → chunk-DY67S3LR.js.map} +0 -0
  40. /package/dist/{chunk-W3YA5BWR.js.map → chunk-E5PVHEAX.js.map} +0 -0
  41. /package/dist/{chunk-VKBMZHMQ.js.map → chunk-KOB73SPD.js.map} +0 -0
  42. /package/dist/{chunk-7UXSWCZZ.js.map → chunk-M4DKOI42.js.map} +0 -0
  43. /package/dist/{chunk-CEJ5RFSG.js.map → chunk-Q4UALQO4.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -66,6 +66,7 @@ __export(index_exports, {
66
66
  useControllerTick: () => useControllerTick,
67
67
  useControllerToasts: () => useControllerToasts,
68
68
  useGetInput: () => useGetInput,
69
+ useHostAudioMutePreference: () => useHostAudioMutePreference,
69
70
  useHostRuntimeInspectionContract: () => useHostRuntimeInspectionContract,
70
71
  useHostTick: () => useHostTick,
71
72
  useInheritedPlatformSettings: () => useInheritedPlatformSettings,
@@ -2545,7 +2546,7 @@ var parseAirJamBridgeInitMessage = (value) => {
2545
2546
  };
2546
2547
 
2547
2548
  // src/runtime/sdk-version.ts
2548
- var AIR_JAM_SDK_VERSION = true ? "0.9.1" : "0.0.0";
2549
+ var AIR_JAM_SDK_VERSION = true ? "0.9.2" : "0.0.0";
2549
2550
 
2550
2551
  // src/runtime/controller-bridge.ts
2551
2552
  var AIRJAM_CONTROLLER_BRIDGE_REQUEST = "AIRJAM_CONTROLLER_BRIDGE_REQUEST";
@@ -5084,8 +5085,78 @@ var useHostTick = (options) => {
5084
5085
  }, [enabled, mode, tickIntervalMs, frameDeltaCapMs, frameStepCap]);
5085
5086
  };
5086
5087
 
5087
- // src/hooks/use-input-writer.ts
5088
+ // src/hooks/use-host-audio-mute-preference.ts
5088
5089
  var import_react13 = require("react");
5090
+ var HOST_AUDIO_MUTE_STORAGE_KEY_PREFIX = "air-jam-host-audio-muted:";
5091
+ var getHostAudioMuteStorageKey = (scope) => `${HOST_AUDIO_MUTE_STORAGE_KEY_PREFIX}${scope}`;
5092
+ var readHostAudioMutePreference = (storageKey, fallback) => {
5093
+ if (typeof window === "undefined") {
5094
+ return fallback;
5095
+ }
5096
+ const raw = window.localStorage.getItem(storageKey);
5097
+ if (raw === "true") {
5098
+ return true;
5099
+ }
5100
+ if (raw === "false") {
5101
+ return false;
5102
+ }
5103
+ return fallback;
5104
+ };
5105
+ var persistHostAudioMutePreference = (storageKey, muted) => {
5106
+ if (typeof window === "undefined") {
5107
+ return;
5108
+ }
5109
+ window.localStorage.setItem(storageKey, muted ? "true" : "false");
5110
+ };
5111
+ var useHostAudioMutePreference = (scope, defaultMuted = false) => {
5112
+ const storageKey = (0, import_react13.useMemo)(() => getHostAudioMuteStorageKey(scope), [scope]);
5113
+ const [muted, setMutedState] = (0, import_react13.useState)(
5114
+ () => readHostAudioMutePreference(storageKey, defaultMuted)
5115
+ );
5116
+ (0, import_react13.useEffect)(() => {
5117
+ setMutedState(readHostAudioMutePreference(storageKey, defaultMuted));
5118
+ }, [defaultMuted, storageKey]);
5119
+ (0, import_react13.useEffect)(() => {
5120
+ if (typeof window === "undefined") {
5121
+ return;
5122
+ }
5123
+ const handleStorage = (event) => {
5124
+ if (event.storageArea !== window.localStorage) {
5125
+ return;
5126
+ }
5127
+ if (event.key !== storageKey) {
5128
+ return;
5129
+ }
5130
+ setMutedState(readHostAudioMutePreference(storageKey, defaultMuted));
5131
+ };
5132
+ window.addEventListener("storage", handleStorage);
5133
+ return () => {
5134
+ window.removeEventListener("storage", handleStorage);
5135
+ };
5136
+ }, [defaultMuted, storageKey]);
5137
+ const setMuted = (0, import_react13.useCallback)(
5138
+ (nextMuted) => {
5139
+ setMutedState(nextMuted);
5140
+ persistHostAudioMutePreference(storageKey, nextMuted);
5141
+ },
5142
+ [storageKey]
5143
+ );
5144
+ const toggleMuted = (0, import_react13.useCallback)(() => {
5145
+ setMutedState((current) => {
5146
+ const nextMuted = !current;
5147
+ persistHostAudioMutePreference(storageKey, nextMuted);
5148
+ return nextMuted;
5149
+ });
5150
+ }, [storageKey]);
5151
+ return {
5152
+ muted,
5153
+ setMuted,
5154
+ toggleMuted
5155
+ };
5156
+ };
5157
+
5158
+ // src/hooks/use-input-writer.ts
5159
+ var import_react14 = require("react");
5089
5160
 
5090
5161
  // src/utils/is-rpc-serializable.ts
5091
5162
  var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
@@ -5132,7 +5203,7 @@ var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
5132
5203
  var useInputWriter = () => {
5133
5204
  useAssertSessionScope("controller", "useInputWriter");
5134
5205
  const { store, getSocket } = useAirJamContext();
5135
- return (0, import_react13.useCallback)(
5206
+ return (0, import_react14.useCallback)(
5136
5207
  (input) => {
5137
5208
  if (typeof input !== "object" || input === null || Array.isArray(input)) {
5138
5209
  emitAirJamDiagnostic({
@@ -5218,11 +5289,11 @@ var useRoom = () => {
5218
5289
  };
5219
5290
 
5220
5291
  // src/hooks/use-send-signal.ts
5221
- var import_react14 = require("react");
5292
+ var import_react15 = require("react");
5222
5293
  var useSendSignal = () => {
5223
5294
  useAssertSessionScope("host", "useSendSignal");
5224
5295
  const { getSocket } = useAirJamContext();
5225
- const sendSignal = (0, import_react14.useCallback)(
5296
+ const sendSignal = (0, import_react15.useCallback)(
5226
5297
  (type, payload, targetId) => {
5227
5298
  const socket = getHostRealtimeClient((role) => getSocket(role));
5228
5299
  if (!socket || !socket.connected) {
@@ -5294,18 +5365,18 @@ var useHostRuntimeInspectionContract = () => createHostRuntimeInspectionContract
5294
5365
  var useControllerRuntimeInspectionContract = () => createControllerRuntimeInspectionContract(useAirJamController());
5295
5366
 
5296
5367
  // src/runtime/session-runtimes.tsx
5297
- var import_react18 = require("react");
5368
+ var import_react19 = require("react");
5298
5369
 
5299
5370
  // src/context/session-providers.tsx
5300
- var import_react15 = require("react");
5371
+ var import_react16 = require("react");
5301
5372
  var import_jsx_runtime4 = require("react/jsx-runtime");
5302
5373
  var createScopedSessionProvider = (scope) => {
5303
5374
  const ScopedSessionProvider = ({
5304
5375
  children,
5305
5376
  ...providerProps
5306
5377
  }) => {
5307
- const runtimeOwnersRef = (0, import_react15.useRef)(/* @__PURE__ */ new Map());
5308
- const claimOwner = (0, import_react15.useCallback)(
5378
+ const runtimeOwnersRef = (0, import_react16.useRef)(/* @__PURE__ */ new Map());
5379
+ const claimOwner = (0, import_react16.useCallback)(
5309
5380
  (kind, token, hookName) => {
5310
5381
  const existing = runtimeOwnersRef.current.get(kind);
5311
5382
  if (existing && existing.token !== token) {
@@ -5338,7 +5409,7 @@ var HostSessionProvider = createScopedSessionProvider("host");
5338
5409
  var ControllerSessionProvider = createScopedSessionProvider("controller");
5339
5410
 
5340
5411
  // src/hooks/internal/use-controller-runtime-api.ts
5341
- var import_react16 = require("react");
5412
+ var import_react17 = require("react");
5342
5413
  var import_zustand9 = require("zustand");
5343
5414
 
5344
5415
  // src/utils/ids.ts
@@ -5553,29 +5624,29 @@ var useControllerRuntimeApi = (options, hookName) => {
5553
5624
  useAssertSessionScope("controller", hookName);
5554
5625
  useClaimSessionRuntimeOwner("controller-runtime", hookName);
5555
5626
  const { store, getSocket, disconnectSocket } = useAirJamContext();
5556
- const nicknameRef = (0, import_react16.useRef)(options.nickname ?? "");
5557
- const avatarIdRef = (0, import_react16.useRef)(options.avatarId ?? "");
5558
- (0, import_react16.useEffect)(() => {
5627
+ const nicknameRef = (0, import_react17.useRef)(options.nickname ?? "");
5628
+ const avatarIdRef = (0, import_react17.useRef)(options.avatarId ?? "");
5629
+ (0, import_react17.useEffect)(() => {
5559
5630
  nicknameRef.current = options.nickname ?? "";
5560
5631
  }, [options.nickname]);
5561
- (0, import_react16.useEffect)(() => {
5632
+ (0, import_react17.useEffect)(() => {
5562
5633
  avatarIdRef.current = options.avatarId ?? "";
5563
5634
  }, [options.avatarId]);
5564
- const embeddedController = (0, import_react16.useMemo)(
5635
+ const embeddedController = (0, import_react17.useMemo)(
5565
5636
  () => readEmbeddedControllerChildSession(),
5566
5637
  []
5567
5638
  );
5568
- const urlRoomId = (0, import_react16.useMemo)(() => getRoomFromLocation(), []);
5569
- const locationCapabilityToken = (0, import_react16.useMemo)(
5639
+ const urlRoomId = (0, import_react17.useMemo)(() => getRoomFromLocation(), []);
5640
+ const locationCapabilityToken = (0, import_react17.useMemo)(
5570
5641
  () => getControllerCapabilityTokenFromLocation(),
5571
5642
  []
5572
5643
  );
5573
5644
  const capabilityToken = options.capabilityToken === void 0 ? locationCapabilityToken : options.capabilityToken;
5574
- const previewDeviceId = (0, import_react16.useMemo)(
5645
+ const previewDeviceId = (0, import_react17.useMemo)(
5575
5646
  () => readPreviewControllerDeviceIdFromLocation(),
5576
5647
  []
5577
5648
  );
5578
- const joinSource = (0, import_react16.useMemo)(
5649
+ const joinSource = (0, import_react17.useMemo)(
5579
5650
  () => resolveControllerJoinSource({
5580
5651
  embeddedRoomId: embeddedController?.roomId,
5581
5652
  optionRoomId: options.roomId ?? null,
@@ -5583,7 +5654,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5583
5654
  }),
5584
5655
  [embeddedController?.roomId, options.roomId, urlRoomId]
5585
5656
  );
5586
- const parsedRoomId = (0, import_react16.useMemo)(() => {
5657
+ const parsedRoomId = (0, import_react17.useMemo)(() => {
5587
5658
  const code = embeddedController?.roomId ?? options.roomId ?? urlRoomId;
5588
5659
  if (!code) return null;
5589
5660
  try {
@@ -5592,7 +5663,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5592
5663
  return null;
5593
5664
  }
5594
5665
  }, [options.roomId, embeddedController, urlRoomId]);
5595
- const deviceId = (0, import_react16.useMemo)(() => {
5666
+ const deviceId = (0, import_react17.useMemo)(() => {
5596
5667
  if (embeddedController) {
5597
5668
  return null;
5598
5669
  }
@@ -5601,7 +5672,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5601
5672
  }
5602
5673
  return getOrCreateControllerDeviceId();
5603
5674
  }, [embeddedController, previewDeviceId]);
5604
- const controllerId = (0, import_react16.useMemo)(() => {
5675
+ const controllerId = (0, import_react17.useMemo)(() => {
5605
5676
  if (embeddedController?.controllerId) {
5606
5677
  return embeddedController.controllerId;
5607
5678
  }
@@ -5621,14 +5692,14 @@ var useControllerRuntimeApi = (options, hookName) => {
5621
5692
  }
5622
5693
  return generateControllerId();
5623
5694
  }, [options.controllerId, embeddedController, parsedRoomId]);
5624
- const onStateRef = (0, import_react16.useRef)(
5695
+ const onStateRef = (0, import_react17.useRef)(
5625
5696
  options.onState
5626
5697
  );
5627
- (0, import_react16.useEffect)(() => {
5698
+ (0, import_react17.useEffect)(() => {
5628
5699
  onStateRef.current = options.onState;
5629
5700
  }, [options.onState]);
5630
5701
  const activeControllerId = (0, import_zustand9.useStore)(store, (state) => state.controllerId);
5631
- (0, import_react16.useEffect)(() => {
5702
+ (0, import_react17.useEffect)(() => {
5632
5703
  updateDevBrowserLogContext({
5633
5704
  role: "controller",
5634
5705
  traceId: void 0,
@@ -5636,7 +5707,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5636
5707
  controllerId: activeControllerId ?? controllerId ?? void 0
5637
5708
  });
5638
5709
  }, [activeControllerId, controllerId, parsedRoomId]);
5639
- (0, import_react16.useEffect)(() => {
5710
+ (0, import_react17.useEffect)(() => {
5640
5711
  return () => {
5641
5712
  updateDevBrowserLogContext({
5642
5713
  role: void 0,
@@ -5645,9 +5716,9 @@ var useControllerRuntimeApi = (options, hookName) => {
5645
5716
  });
5646
5717
  };
5647
5718
  }, []);
5648
- const [reconnectKey, setReconnectKey] = (0, import_react16.useState)(0);
5649
- const leaveIssuedRef = (0, import_react16.useRef)(false);
5650
- const emitControllerRuntimeEvent = (0, import_react16.useCallback)(
5719
+ const [reconnectKey, setReconnectKey] = (0, import_react17.useState)(0);
5720
+ const leaveIssuedRef = (0, import_react17.useRef)(false);
5721
+ const emitControllerRuntimeEvent = (0, import_react17.useCallback)(
5651
5722
  ({
5652
5723
  event,
5653
5724
  level = "info",
@@ -5667,9 +5738,9 @@ var useControllerRuntimeApi = (options, hookName) => {
5667
5738
  },
5668
5739
  [controllerId]
5669
5740
  );
5670
- const lastObservedStateVersionRef = (0, import_react16.useRef)(null);
5671
- const emittedInvariantKeysRef = (0, import_react16.useRef)(/* @__PURE__ */ new Set());
5672
- const emitInvariantOnce = (0, import_react16.useCallback)(
5741
+ const lastObservedStateVersionRef = (0, import_react17.useRef)(null);
5742
+ const emittedInvariantKeysRef = (0, import_react17.useRef)(/* @__PURE__ */ new Set());
5743
+ const emitInvariantOnce = (0, import_react17.useCallback)(
5673
5744
  ({
5674
5745
  code,
5675
5746
  roomId,
@@ -5694,11 +5765,11 @@ var useControllerRuntimeApi = (options, hookName) => {
5694
5765
  },
5695
5766
  [emitControllerRuntimeEvent]
5696
5767
  );
5697
- const socket = (0, import_react16.useMemo)(
5768
+ const socket = (0, import_react17.useMemo)(
5698
5769
  () => parsedRoomId ? getControllerRealtimeClient((role) => getSocket(role)) : null,
5699
5770
  [parsedRoomId, getSocket]
5700
5771
  );
5701
- const reconnect = (0, import_react16.useCallback)(() => {
5772
+ const reconnect = (0, import_react17.useCallback)(() => {
5702
5773
  if (!parsedRoomId) return;
5703
5774
  socket?.disconnect();
5704
5775
  if (!embeddedController) {
@@ -5706,7 +5777,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5706
5777
  }
5707
5778
  setReconnectKey((prev) => prev + 1);
5708
5779
  }, [parsedRoomId, disconnectSocket, socket, embeddedController]);
5709
- const leave = (0, import_react16.useCallback)(async () => {
5780
+ const leave = (0, import_react17.useCallback)(async () => {
5710
5781
  const storeState = store.getState();
5711
5782
  const activeControllerId2 = storeState.controllerId;
5712
5783
  if (!socket || !parsedRoomId || !activeControllerId2) {
@@ -5754,7 +5825,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5754
5825
  );
5755
5826
  });
5756
5827
  }, [embeddedController, parsedRoomId, socket, store]);
5757
- (0, import_react16.useEffect)(() => {
5828
+ (0, import_react17.useEffect)(() => {
5758
5829
  if (!socket) return;
5759
5830
  const handleSignal = (signal) => {
5760
5831
  if (signal.type !== "HAPTIC") return;
@@ -5790,7 +5861,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5790
5861
  socket.off("server:signal", handleSignal);
5791
5862
  };
5792
5863
  }, [socket]);
5793
- (0, import_react16.useEffect)(() => {
5864
+ (0, import_react17.useEffect)(() => {
5794
5865
  if (typeof window === "undefined" || !previewDeviceId || embeddedController || !socket) {
5795
5866
  return;
5796
5867
  }
@@ -5818,7 +5889,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5818
5889
  window.removeEventListener("message", handleMessage);
5819
5890
  };
5820
5891
  }, [disconnectSocket, embeddedController, leave, previewDeviceId, socket]);
5821
- (0, import_react16.useEffect)(() => {
5892
+ (0, import_react17.useEffect)(() => {
5822
5893
  if (!previewDeviceId || !parsedRoomId || embeddedController || !socket) {
5823
5894
  return;
5824
5895
  }
@@ -5839,7 +5910,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5839
5910
  );
5840
5911
  };
5841
5912
  }, [embeddedController, parsedRoomId, previewDeviceId, socket, store]);
5842
- (0, import_react16.useEffect)(() => {
5913
+ (0, import_react17.useEffect)(() => {
5843
5914
  const storeState = store.getState();
5844
5915
  storeState.setMode(detectRunMode());
5845
5916
  storeState.setRole("controller");
@@ -6131,13 +6202,13 @@ var useControllerRuntimeApi = (options, hookName) => {
6131
6202
  capabilityToken,
6132
6203
  emitInvariantOnce
6133
6204
  ]);
6134
- const setNickname = (0, import_react16.useCallback)((value) => {
6205
+ const setNickname = (0, import_react17.useCallback)((value) => {
6135
6206
  nicknameRef.current = value;
6136
6207
  }, []);
6137
- const setAvatarId = (0, import_react16.useCallback)((value) => {
6208
+ const setAvatarId = (0, import_react17.useCallback)((value) => {
6138
6209
  avatarIdRef.current = value;
6139
6210
  }, []);
6140
- const updatePlayerProfile = (0, import_react16.useCallback)(
6211
+ const updatePlayerProfile = (0, import_react17.useCallback)(
6141
6212
  (patch) => {
6142
6213
  const parsedPatch = playerProfilePatchSchema.safeParse(patch);
6143
6214
  if (!parsedPatch.success) {
@@ -6174,7 +6245,7 @@ var useControllerRuntimeApi = (options, hookName) => {
6174
6245
  },
6175
6246
  [parsedRoomId, socket, store, embeddedController]
6176
6247
  );
6177
- const sendSystemCommand = (0, import_react16.useCallback)(
6248
+ const sendSystemCommand = (0, import_react17.useCallback)(
6178
6249
  (command) => {
6179
6250
  const storeState = store.getState();
6180
6251
  if (!parsedRoomId || !storeState.controllerId || !socket) return;
@@ -6189,7 +6260,7 @@ var useControllerRuntimeApi = (options, hookName) => {
6189
6260
  },
6190
6261
  [parsedRoomId, socket, store]
6191
6262
  );
6192
- return (0, import_react16.useMemo)(
6263
+ return (0, import_react17.useMemo)(
6193
6264
  () => ({
6194
6265
  sendSystemCommand,
6195
6266
  setNickname,
@@ -6212,7 +6283,7 @@ var useControllerRuntimeApi = (options, hookName) => {
6212
6283
  };
6213
6284
 
6214
6285
  // src/hooks/internal/use-host-runtime-api.ts
6215
- var import_react17 = require("react");
6286
+ var import_react18 = require("react");
6216
6287
  var import_zod13 = require("zod");
6217
6288
  var import_zustand10 = require("zustand");
6218
6289
 
@@ -6443,10 +6514,10 @@ var useHostRuntimeApi = (options, hookName) => {
6443
6514
  useAssertSessionScope("host", hookName);
6444
6515
  useClaimSessionRuntimeOwner("host-runtime", hookName);
6445
6516
  const { config, store, getSocket, disconnectSocket, inputManager } = useAirJamContext();
6446
- const embeddedHost = (0, import_react17.useMemo)(() => readEmbeddedHostChildSession(), []);
6517
+ const embeddedHost = (0, import_react18.useMemo)(() => readEmbeddedHostChildSession(), []);
6447
6518
  const shouldConnect = true;
6448
6519
  const storeRoomId = (0, import_zustand10.useStore)(store, (s) => s.roomId);
6449
- const parsedRoomId = (0, import_react17.useMemo)(() => {
6520
+ const parsedRoomId = (0, import_react18.useMemo)(() => {
6450
6521
  if (embeddedHost) {
6451
6522
  return embeddedHost.roomId;
6452
6523
  }
@@ -6466,32 +6537,32 @@ var useHostRuntimeApi = (options, hookName) => {
6466
6537
  }
6467
6538
  return null;
6468
6539
  }, [options.roomId, storeRoomId, embeddedHost]);
6469
- const [controllerCapability, setControllerCapability] = (0, import_react17.useState)(null);
6470
- const joinUrlBuildKey = (0, import_react17.useMemo)(
6540
+ const [controllerCapability, setControllerCapability] = (0, import_react18.useState)(null);
6541
+ const joinUrlBuildKey = (0, import_react18.useMemo)(
6471
6542
  () => parsedRoomId ? `${parsedRoomId}\0${config.publicHost ?? ""}\0${controllerCapability?.token ?? ""}` : null,
6472
6543
  [config.publicHost, controllerCapability?.token, parsedRoomId]
6473
6544
  );
6474
- const [computedJoinUrl, setComputedJoinUrl] = (0, import_react17.useState)({
6545
+ const [computedJoinUrl, setComputedJoinUrl] = (0, import_react18.useState)({
6475
6546
  key: null,
6476
6547
  url: "",
6477
6548
  error: false
6478
6549
  });
6479
- const onPlayerJoinRef = (0, import_react17.useRef)(options.onPlayerJoin);
6480
- const onPlayerLeaveRef = (0, import_react17.useRef)(options.onPlayerLeave);
6481
- const parsedRoomIdRef = (0, import_react17.useRef)(parsedRoomId);
6482
- (0, import_react17.useEffect)(() => {
6550
+ const onPlayerJoinRef = (0, import_react18.useRef)(options.onPlayerJoin);
6551
+ const onPlayerLeaveRef = (0, import_react18.useRef)(options.onPlayerLeave);
6552
+ const parsedRoomIdRef = (0, import_react18.useRef)(parsedRoomId);
6553
+ (0, import_react18.useEffect)(() => {
6483
6554
  onPlayerJoinRef.current = options.onPlayerJoin;
6484
6555
  onPlayerLeaveRef.current = options.onPlayerLeave;
6485
6556
  }, [options.onPlayerJoin, options.onPlayerLeave]);
6486
- (0, import_react17.useEffect)(() => {
6557
+ (0, import_react18.useEffect)(() => {
6487
6558
  parsedRoomIdRef.current = parsedRoomId;
6488
6559
  }, [parsedRoomId]);
6489
- const socket = (0, import_react17.useMemo)(
6560
+ const socket = (0, import_react18.useMemo)(
6490
6561
  () => shouldConnect ? getHostRealtimeClient((role) => getSocket(role)) : null,
6491
6562
  [shouldConnect, getSocket]
6492
6563
  );
6493
6564
  const setRegisteredRoomId = (0, import_zustand10.useStore)(store, (s) => s.setRegisteredRoomId);
6494
- const hydrateHostRoster = (0, import_react17.useCallback)(
6565
+ const hydrateHostRoster = (0, import_react18.useCallback)(
6495
6566
  (players, controllers) => {
6496
6567
  const latestState = store.getState();
6497
6568
  latestState.resetPlayers();
@@ -6505,7 +6576,7 @@ var useHostRuntimeApi = (options, hookName) => {
6505
6576
  },
6506
6577
  [store]
6507
6578
  );
6508
- const canEmitAuthoritativeHostState = (0, import_react17.useCallback)(
6579
+ const canEmitAuthoritativeHostState = (0, import_react18.useCallback)(
6509
6580
  (roomId) => {
6510
6581
  if (!socket || !socket.connected || !roomId) {
6511
6582
  return false;
@@ -6515,7 +6586,7 @@ var useHostRuntimeApi = (options, hookName) => {
6515
6586
  },
6516
6587
  [socket, store]
6517
6588
  );
6518
- const emitHostRuntimeEvent = (0, import_react17.useCallback)(
6589
+ const emitHostRuntimeEvent = (0, import_react18.useCallback)(
6519
6590
  ({
6520
6591
  event,
6521
6592
  level = "info",
@@ -6534,9 +6605,9 @@ var useHostRuntimeApi = (options, hookName) => {
6534
6605
  },
6535
6606
  []
6536
6607
  );
6537
- const lastObservedStateVersionRef = (0, import_react17.useRef)(null);
6538
- const emittedInvariantKeysRef = (0, import_react17.useRef)(/* @__PURE__ */ new Set());
6539
- const emitInvariantOnce = (0, import_react17.useCallback)(
6608
+ const lastObservedStateVersionRef = (0, import_react18.useRef)(null);
6609
+ const emittedInvariantKeysRef = (0, import_react18.useRef)(/* @__PURE__ */ new Set());
6610
+ const emitInvariantOnce = (0, import_react18.useCallback)(
6540
6611
  ({
6541
6612
  code,
6542
6613
  roomId,
@@ -6561,7 +6632,7 @@ var useHostRuntimeApi = (options, hookName) => {
6561
6632
  },
6562
6633
  [emitHostRuntimeEvent]
6563
6634
  );
6564
- const sendState = (0, import_react17.useCallback)(
6635
+ const sendState = (0, import_react18.useCallback)(
6565
6636
  (state) => {
6566
6637
  const activeSocket = socket;
6567
6638
  const activeRoomId = parsedRoomIdRef.current;
@@ -6580,7 +6651,7 @@ var useHostRuntimeApi = (options, hookName) => {
6580
6651
  },
6581
6652
  [canEmitAuthoritativeHostState, socket]
6582
6653
  );
6583
- const setRuntimeState = (0, import_react17.useCallback)(
6654
+ const setRuntimeState = (0, import_react18.useCallback)(
6584
6655
  (runtimeState) => {
6585
6656
  const activeRoomId = parsedRoomIdRef.current;
6586
6657
  if (store.getState().runtimeState === runtimeState) {
@@ -6593,13 +6664,13 @@ var useHostRuntimeApi = (options, hookName) => {
6593
6664
  },
6594
6665
  [canEmitAuthoritativeHostState, sendState, store]
6595
6666
  );
6596
- const pauseRuntime = (0, import_react17.useCallback)(() => {
6667
+ const pauseRuntime = (0, import_react18.useCallback)(() => {
6597
6668
  setRuntimeState("paused");
6598
6669
  }, [setRuntimeState]);
6599
- const resumeRuntime = (0, import_react17.useCallback)(() => {
6670
+ const resumeRuntime = (0, import_react18.useCallback)(() => {
6600
6671
  setRuntimeState("playing");
6601
6672
  }, [setRuntimeState]);
6602
- const sendSignal = (0, import_react17.useCallback)(
6673
+ const sendSignal = (0, import_react18.useCallback)(
6603
6674
  (type, payload, targetId) => {
6604
6675
  if (!socket || !socket.connected) {
6605
6676
  return;
@@ -6613,7 +6684,7 @@ var useHostRuntimeApi = (options, hookName) => {
6613
6684
  },
6614
6685
  [socket]
6615
6686
  );
6616
- const reconnect = (0, import_react17.useCallback)(() => {
6687
+ const reconnect = (0, import_react18.useCallback)(() => {
6617
6688
  socket?.disconnect();
6618
6689
  if (!embeddedHost) {
6619
6690
  disconnectSocket("host");
@@ -6622,7 +6693,7 @@ var useHostRuntimeApi = (options, hookName) => {
6622
6693
  socket.connect();
6623
6694
  }
6624
6695
  }, [socket, embeddedHost, disconnectSocket]);
6625
- const removeController = (0, import_react17.useCallback)(
6696
+ const removeController = (0, import_react18.useCallback)(
6626
6697
  async (controllerId) => {
6627
6698
  const activeRoomId = parsedRoomIdRef.current;
6628
6699
  if (!socket || !activeRoomId) {
@@ -6639,7 +6710,7 @@ var useHostRuntimeApi = (options, hookName) => {
6639
6710
  },
6640
6711
  [socket]
6641
6712
  );
6642
- const resetRoom = (0, import_react17.useCallback)(async () => {
6713
+ const resetRoom = (0, import_react18.useCallback)(async () => {
6643
6714
  const activeRoomId = parsedRoomIdRef.current;
6644
6715
  if (!socket || !activeRoomId) {
6645
6716
  return {
@@ -6682,7 +6753,7 @@ var useHostRuntimeApi = (options, hookName) => {
6682
6753
  socket,
6683
6754
  store
6684
6755
  ]);
6685
- (0, import_react17.useEffect)(() => {
6756
+ (0, import_react18.useEffect)(() => {
6686
6757
  if (embeddedHost?.joinUrl) {
6687
6758
  return;
6688
6759
  }
@@ -6725,19 +6796,19 @@ var useHostRuntimeApi = (options, hookName) => {
6725
6796
  ]);
6726
6797
  const joinUrl = embeddedHost?.joinUrl ? embeddedHost.joinUrl : computedJoinUrl.key === joinUrlBuildKey ? computedJoinUrl.url : "";
6727
6798
  const joinUrlStatus = embeddedHost?.joinUrl ? "ready" : !joinUrlBuildKey ? "loading" : computedJoinUrl.key !== joinUrlBuildKey ? "loading" : computedJoinUrl.error ? "unavailable" : computedJoinUrl.url ? "ready" : "loading";
6728
- const reconnectRetryTimeoutRef = (0, import_react17.useRef)(
6799
+ const reconnectRetryTimeoutRef = (0, import_react18.useRef)(
6729
6800
  null
6730
6801
  );
6731
- const setDevHostTraceId = (0, import_react17.useCallback)((traceId) => {
6802
+ const setDevHostTraceId = (0, import_react18.useCallback)((traceId) => {
6732
6803
  updateDevBrowserLogContext({ traceId });
6733
6804
  }, []);
6734
- (0, import_react17.useEffect)(() => {
6805
+ (0, import_react18.useEffect)(() => {
6735
6806
  updateDevBrowserLogContext({
6736
6807
  role: "host",
6737
6808
  roomId: parsedRoomId ?? void 0
6738
6809
  });
6739
6810
  }, [parsedRoomId]);
6740
- (0, import_react17.useEffect)(() => {
6811
+ (0, import_react18.useEffect)(() => {
6741
6812
  return () => {
6742
6813
  updateDevBrowserLogContext({
6743
6814
  role: void 0,
@@ -6746,13 +6817,13 @@ var useHostRuntimeApi = (options, hookName) => {
6746
6817
  });
6747
6818
  };
6748
6819
  }, []);
6749
- const hostGrantResponseSchema = (0, import_react17.useMemo)(
6820
+ const hostGrantResponseSchema = (0, import_react18.useMemo)(
6750
6821
  () => import_zod13.z.object({
6751
6822
  hostGrant: import_zod13.z.string().min(1)
6752
6823
  }),
6753
6824
  []
6754
6825
  );
6755
- (0, import_react17.useEffect)(() => {
6826
+ (0, import_react18.useEffect)(() => {
6756
6827
  const storeState = store.getState();
6757
6828
  const initialRoomId = parsedRoomIdRef.current;
6758
6829
  storeState.setMode(detectRunMode());
@@ -7226,7 +7297,7 @@ var useHostRuntimeApi = (options, hookName) => {
7226
7297
  emitInvariantOnce,
7227
7298
  hydrateHostRoster
7228
7299
  ]);
7229
- const getInput = (0, import_react17.useCallback)(
7300
+ const getInput = (0, import_react18.useCallback)(
7230
7301
  (controllerId) => {
7231
7302
  if (!inputManager) {
7232
7303
  return void 0;
@@ -7235,7 +7306,7 @@ var useHostRuntimeApi = (options, hookName) => {
7235
7306
  },
7236
7307
  [inputManager]
7237
7308
  );
7238
- return (0, import_react17.useMemo)(
7309
+ return (0, import_react18.useMemo)(
7239
7310
  () => ({
7240
7311
  roomId: parsedRoomId ?? "",
7241
7312
  joinUrl,
@@ -7274,7 +7345,7 @@ var useHostRuntimeApi = (options, hookName) => {
7274
7345
  var import_jsx_runtime5 = require("react/jsx-runtime");
7275
7346
  var HostRuntimeInspectionPublisher = () => {
7276
7347
  const inspection = useHostRuntimeInspectionContract();
7277
- (0, import_react18.useEffect)(() => {
7348
+ (0, import_react19.useEffect)(() => {
7278
7349
  if (typeof window === "undefined") {
7279
7350
  return;
7280
7351
  }
@@ -7289,7 +7360,7 @@ var HostRuntimeInspectionPublisher = () => {
7289
7360
  };
7290
7361
  var ControllerRuntimeInspectionPublisher = () => {
7291
7362
  const inspection = useControllerRuntimeInspectionContract();
7292
- (0, import_react18.useEffect)(() => {
7363
+ (0, import_react19.useEffect)(() => {
7293
7364
  if (typeof window === "undefined") {
7294
7365
  return;
7295
7366
  }
@@ -7412,7 +7483,7 @@ var toShellMatchPhase = (phase) => {
7412
7483
 
7413
7484
  // src/runtime/air-jam-error-boundary.tsx
7414
7485
  var import_lucide_react = require("lucide-react");
7415
- var import_react19 = require("react");
7486
+ var import_react20 = require("react");
7416
7487
  var import_jsx_runtime6 = require("react/jsx-runtime");
7417
7488
  var toError = (value) => {
7418
7489
  if (value instanceof Error) {
@@ -7512,19 +7583,19 @@ var DefaultFallback = ({
7512
7583
  isEmbedded
7513
7584
  }) => {
7514
7585
  const digest = createErrorDigest(error);
7515
- const [isMinimized, setIsMinimized] = (0, import_react19.useState)(false);
7516
- const [copyState, setCopyState] = (0, import_react19.useState)(
7586
+ const [isMinimized, setIsMinimized] = (0, import_react20.useState)(false);
7587
+ const [copyState, setCopyState] = (0, import_react20.useState)(
7517
7588
  "idle"
7518
7589
  );
7519
- const copyResetTimeoutRef = (0, import_react19.useRef)(null);
7520
- (0, import_react19.useEffect)(() => {
7590
+ const copyResetTimeoutRef = (0, import_react20.useRef)(null);
7591
+ (0, import_react20.useEffect)(() => {
7521
7592
  return () => {
7522
7593
  if (copyResetTimeoutRef.current !== null && typeof window !== "undefined") {
7523
7594
  window.clearTimeout(copyResetTimeoutRef.current);
7524
7595
  }
7525
7596
  };
7526
7597
  }, []);
7527
- const scheduleCopyStatusReset = (0, import_react19.useCallback)(() => {
7598
+ const scheduleCopyStatusReset = (0, import_react20.useCallback)(() => {
7528
7599
  if (typeof window === "undefined") {
7529
7600
  return;
7530
7601
  }
@@ -7536,7 +7607,7 @@ var DefaultFallback = ({
7536
7607
  copyResetTimeoutRef.current = null;
7537
7608
  }, 1800);
7538
7609
  }, []);
7539
- const handleCopy = (0, import_react19.useCallback)(async () => {
7610
+ const handleCopy = (0, import_react20.useCallback)(async () => {
7540
7611
  try {
7541
7612
  await copyTextToClipboard(
7542
7613
  createCopyPayload({
@@ -7964,7 +8035,7 @@ var DefaultFallback = ({
7964
8035
  }
7965
8036
  );
7966
8037
  };
7967
- var AirJamErrorBoundary = class extends import_react19.Component {
8038
+ var AirJamErrorBoundary = class extends import_react20.Component {
7968
8039
  state = {
7969
8040
  error: null
7970
8041
  };
@@ -8349,7 +8420,7 @@ var agentAction = {
8349
8420
  var defineAirJamAgentContract = (contract) => contract;
8350
8421
 
8351
8422
  // src/store/create-air-jam-store.ts
8352
- var import_react20 = require("react");
8423
+ var import_react21 = require("react");
8353
8424
  var import_zustand11 = require("zustand");
8354
8425
  var INTERNAL_ACTION_PREFIX = "_";
8355
8426
  var UNRESOLVED_ACTOR_ID = "unknown";
@@ -8877,11 +8948,11 @@ function createAirJamStore2(initializer, options) {
8877
8948
  );
8878
8949
  const blockArcadeShellHostBroadcast = resolvedStoreDomain === AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN && hostArcadeRestore.phase !== "idle";
8879
8950
  const canBroadcastHostState = role === "host" && !!roomId && registeredRoomId === roomId && !blockArcadeShellHostBroadcast;
8880
- const connectedPlayerIds = (0, import_react20.useMemo)(
8951
+ const connectedPlayerIds = (0, import_react21.useMemo)(
8881
8952
  () => Array.from(new Set(players.map((player) => player.id))).sort(),
8882
8953
  [players]
8883
8954
  );
8884
- const playerRosterKey = (0, import_react20.useMemo)(
8955
+ const playerRosterKey = (0, import_react21.useMemo)(
8885
8956
  () => players.map((player) => player.id).sort().join(","),
8886
8957
  [players]
8887
8958
  );
@@ -8902,7 +8973,7 @@ function createAirJamStore2(initializer, options) {
8902
8973
  socket.id ?? "socket",
8903
8974
  role === "controller" ? connectionStatus : "host"
8904
8975
  ].join(":") : null;
8905
- (0, import_react20.useEffect)(() => {
8976
+ (0, import_react21.useEffect)(() => {
8906
8977
  if (!runtimeBindingKey || !socket || !roomId || !role) {
8907
8978
  return;
8908
8979
  }
@@ -8937,7 +9008,7 @@ function createAirJamStore2(initializer, options) {
8937
9008
  socket?.id,
8938
9009
  resolvedStoreDomain
8939
9010
  ]);
8940
- (0, import_react20.useEffect)(() => {
9011
+ (0, import_react21.useEffect)(() => {
8941
9012
  if (!runtimeBindingKey || role !== "host" || !canBroadcastHostState || !roomId) {
8942
9013
  return;
8943
9014
  }
@@ -8968,7 +9039,7 @@ function createAirJamStore2(initializer, options) {
8968
9039
  canBroadcastHostState,
8969
9040
  runtimeBindingKey
8970
9041
  ]);
8971
- const dispatchedActions = (0, import_react20.useMemo)(
9042
+ const dispatchedActions = (0, import_react21.useMemo)(
8972
9043
  () => createDispatchedActions({ kind: "default" }),
8973
9044
  []
8974
9045
  );
@@ -9003,13 +9074,13 @@ function createAirJamStore2(initializer, options) {
9003
9074
  };
9004
9075
  };
9005
9076
  const useHostActionListener = (listener, options2) => {
9006
- const listenerRef = (0, import_react20.useRef)(listener);
9007
- (0, import_react20.useEffect)(() => {
9077
+ const listenerRef = (0, import_react21.useRef)(listener);
9078
+ (0, import_react21.useEffect)(() => {
9008
9079
  listenerRef.current = listener;
9009
9080
  }, [listener]);
9010
9081
  const includeRejected = options2?.includeRejected ?? false;
9011
9082
  const actionNamesKey = options2?.actionNames?.join("\0") ?? "";
9012
- (0, import_react20.useEffect)(() => {
9083
+ (0, import_react21.useEffect)(() => {
9013
9084
  return subscribeHostActions((event) => {
9014
9085
  listenerRef.current(event);
9015
9086
  }, options2);
@@ -9017,8 +9088,8 @@ function createAirJamStore2(initializer, options) {
9017
9088
  };
9018
9089
  const useLiveStateRef = () => {
9019
9090
  const latestState = useSyncedStore((state) => state);
9020
- const stateRef = (0, import_react20.useRef)(latestState);
9021
- (0, import_react20.useEffect)(() => {
9091
+ const stateRef = (0, import_react21.useRef)(latestState);
9092
+ (0, import_react21.useEffect)(() => {
9022
9093
  stateRef.current = latestState;
9023
9094
  }, [latestState]);
9024
9095
  return stateRef;
@@ -9080,6 +9151,7 @@ function createAirJamStore2(initializer, options) {
9080
9151
  useControllerTick,
9081
9152
  useControllerToasts,
9082
9153
  useGetInput,
9154
+ useHostAudioMutePreference,
9083
9155
  useHostRuntimeInspectionContract,
9084
9156
  useHostTick,
9085
9157
  useInheritedPlatformSettings,