@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.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,
@@ -83,15 +84,342 @@ module.exports = __toCommonJS(index_exports);
83
84
  var import_react3 = require("react");
84
85
  var import_zustand3 = require("zustand");
85
86
 
87
+ // src/runtime-topology.ts
88
+ var RUNTIME_MODES = /* @__PURE__ */ new Set([
89
+ "standalone-dev",
90
+ "standalone-secure",
91
+ "arcade-live",
92
+ "arcade-built",
93
+ "self-hosted-production",
94
+ "hosted-release"
95
+ ]);
96
+ var SURFACE_ROLES = /* @__PURE__ */ new Set([
97
+ "host",
98
+ "controller",
99
+ "platform-host",
100
+ "platform-controller"
101
+ ]);
102
+ var PROXY_STRATEGIES = /* @__PURE__ */ new Set([
103
+ "none",
104
+ "platform-proxy",
105
+ "dev-proxy"
106
+ ]);
107
+ var PROJECT_RUNTIME_MODES = /* @__PURE__ */ new Set([
108
+ "standalone-dev",
109
+ "standalone-secure",
110
+ "self-hosted-production",
111
+ "hosted-release"
112
+ ]);
113
+ var LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES = /* @__PURE__ */ new Set([
114
+ "standalone-dev",
115
+ "standalone-secure",
116
+ "arcade-live",
117
+ "arcade-built"
118
+ ]);
119
+ var AIR_JAM_RUNTIME_TOPOLOGY_ENV_KEYS = [
120
+ "VITE_AIR_JAM_RUNTIME_TOPOLOGY",
121
+ "NEXT_PUBLIC_AIR_JAM_RUNTIME_TOPOLOGY",
122
+ "AIR_JAM_RUNTIME_TOPOLOGY"
123
+ ];
124
+ var AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX = "aj_topology_";
125
+ var AIR_JAM_RUNTIME_TOPOLOGY_WINDOW_KEY = "__AIR_JAM_RUNTIME_TOPOLOGY__";
126
+ var REQUIRED_QUERY_KEYS = [
127
+ "runtime_mode",
128
+ "surface_role",
129
+ "app_origin",
130
+ "backend_origin",
131
+ "public_host",
132
+ "asset_base_path",
133
+ "secure_transport",
134
+ "embedded",
135
+ "proxy_strategy"
136
+ ];
137
+ var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
138
+ var assertString = (value, fieldName) => {
139
+ if (typeof value !== "string") {
140
+ throw new Error(`Runtime topology field "${fieldName}" must be a string.`);
141
+ }
142
+ const normalized = value.trim();
143
+ if (!normalized) {
144
+ throw new Error(`Runtime topology field "${fieldName}" cannot be empty.`);
145
+ }
146
+ return normalized;
147
+ };
148
+ var assertBoolean = (value, fieldName) => {
149
+ if (typeof value !== "boolean") {
150
+ throw new Error(`Runtime topology field "${fieldName}" must be a boolean.`);
151
+ }
152
+ return value;
153
+ };
154
+ var assertUrl = (value, fieldName) => {
155
+ const normalized = assertString(value, fieldName);
156
+ const withScheme = normalized.includes("://") ? normalized : `http://${normalized}`;
157
+ let parsed;
158
+ try {
159
+ parsed = new URL(withScheme);
160
+ } catch {
161
+ throw new Error(
162
+ `Runtime topology field "${fieldName}" must be a valid absolute URL.`
163
+ );
164
+ }
165
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
166
+ throw new Error(
167
+ `Runtime topology field "${fieldName}" must use http or https.`
168
+ );
169
+ }
170
+ parsed.pathname = "";
171
+ parsed.search = "";
172
+ parsed.hash = "";
173
+ return parsed.origin;
174
+ };
175
+ var normalizeAssetBasePath = (value) => {
176
+ if (value == null) {
177
+ return "/";
178
+ }
179
+ const normalized = assertString(value, "assetBasePath");
180
+ if (normalized === "/") {
181
+ return normalized;
182
+ }
183
+ const withLeadingSlash = normalized.startsWith("/") ? normalized : `/${normalized}`;
184
+ return withLeadingSlash.endsWith("/") && withLeadingSlash.length > 1 ? withLeadingSlash.slice(0, -1) : withLeadingSlash;
185
+ };
186
+ var fromBooleanParam = (value, fieldName) => {
187
+ if (value === "true") {
188
+ return true;
189
+ }
190
+ if (value === "false") {
191
+ return false;
192
+ }
193
+ throw new Error(
194
+ `Runtime topology query field "${fieldName}" must be "true" or "false".`
195
+ );
196
+ };
197
+ var resolveDefaultSocketOrigin = ({
198
+ proxyStrategy,
199
+ appOrigin,
200
+ backendOrigin
201
+ }) => {
202
+ if (proxyStrategy === "none") {
203
+ return backendOrigin;
204
+ }
205
+ return appOrigin;
206
+ };
207
+ var inferSecureTransport = ({
208
+ runtimeMode,
209
+ appOrigin,
210
+ backendOrigin,
211
+ socketOrigin,
212
+ publicHost
213
+ }) => {
214
+ if (runtimeMode === "standalone-secure") {
215
+ return true;
216
+ }
217
+ return [appOrigin, backendOrigin, socketOrigin, publicHost].every(
218
+ (origin) => origin.startsWith("https://")
219
+ );
220
+ };
221
+ var resolveRuntimeTopology = (input) => {
222
+ if (!isObject(input)) {
223
+ throw new Error("Runtime topology input must be an object.");
224
+ }
225
+ const runtimeMode = assertString(
226
+ input.runtimeMode,
227
+ "runtimeMode"
228
+ );
229
+ if (!RUNTIME_MODES.has(runtimeMode)) {
230
+ throw new Error(
231
+ `Unsupported runtime mode "${runtimeMode}". Use one of: ${Array.from(RUNTIME_MODES).join(", ")}.`
232
+ );
233
+ }
234
+ const surfaceRole = assertString(
235
+ input.surfaceRole,
236
+ "surfaceRole"
237
+ );
238
+ if (!SURFACE_ROLES.has(surfaceRole)) {
239
+ throw new Error(
240
+ `Unsupported surface role "${surfaceRole}". Use one of: ${Array.from(SURFACE_ROLES).join(", ")}.`
241
+ );
242
+ }
243
+ const appOrigin = assertUrl(input.appOrigin, "appOrigin");
244
+ const backendOrigin = assertUrl(input.backendOrigin, "backendOrigin");
245
+ const proxyStrategy = input.proxyStrategy == null ? "none" : assertString(input.proxyStrategy, "proxyStrategy");
246
+ if (!PROXY_STRATEGIES.has(proxyStrategy)) {
247
+ throw new Error(
248
+ `Unsupported proxy strategy "${proxyStrategy}". Use one of: ${Array.from(PROXY_STRATEGIES).join(", ")}.`
249
+ );
250
+ }
251
+ const socketOrigin = input.socketOrigin != null ? assertUrl(input.socketOrigin, "socketOrigin") : resolveDefaultSocketOrigin({ proxyStrategy, appOrigin, backendOrigin });
252
+ const publicHost = input.publicHost != null ? assertUrl(input.publicHost, "publicHost") : appOrigin;
253
+ const assetBasePath = normalizeAssetBasePath(input.assetBasePath);
254
+ const embedded = input.embedded == null ? false : assertBoolean(input.embedded, "embedded");
255
+ const embedParentOrigin = input.embedParentOrigin == null ? void 0 : assertUrl(input.embedParentOrigin, "embedParentOrigin");
256
+ if (embedded && !embedParentOrigin) {
257
+ throw new Error(
258
+ 'Embedded runtimes must provide "embedParentOrigin" in their topology.'
259
+ );
260
+ }
261
+ if (!embedded && embedParentOrigin) {
262
+ throw new Error(
263
+ 'Non-embedded runtimes cannot provide "embedParentOrigin" in their topology.'
264
+ );
265
+ }
266
+ const secureTransport = input.secureTransport == null ? inferSecureTransport({
267
+ runtimeMode,
268
+ appOrigin,
269
+ backendOrigin,
270
+ socketOrigin,
271
+ publicHost
272
+ }) : assertBoolean(input.secureTransport, "secureTransport");
273
+ return {
274
+ runtimeMode,
275
+ surfaceRole,
276
+ appOrigin,
277
+ backendOrigin,
278
+ socketOrigin,
279
+ publicHost,
280
+ assetBasePath,
281
+ secureTransport,
282
+ embedded,
283
+ ...embedParentOrigin ? { embedParentOrigin } : {},
284
+ proxyStrategy
285
+ };
286
+ };
287
+ var resolveProjectRuntimeTopology = (input) => {
288
+ if (!isObject(input)) {
289
+ throw new Error("Project runtime topology input must be an object.");
290
+ }
291
+ const requestedRuntimeMode = input.runtimeMode == null ? input.secureTransport ? "standalone-secure" : "standalone-dev" : assertString(input.runtimeMode, "runtimeMode");
292
+ if (!PROJECT_RUNTIME_MODES.has(requestedRuntimeMode)) {
293
+ throw new Error(
294
+ `Unsupported project runtime mode "${requestedRuntimeMode}". Use one of: ${Array.from(PROJECT_RUNTIME_MODES).join(", ")}.`
295
+ );
296
+ }
297
+ const proxyStrategy = input.proxyStrategy ?? (requestedRuntimeMode === "standalone-dev" || requestedRuntimeMode === "standalone-secure" ? "dev-proxy" : "none");
298
+ const appOrigin = assertUrl(input.appOrigin, "appOrigin");
299
+ const backendOrigin = input.backendOrigin != null ? assertUrl(input.backendOrigin, "backendOrigin") : appOrigin;
300
+ const publicHost = input.publicHost != null ? assertUrl(input.publicHost, "publicHost") : appOrigin;
301
+ return resolveRuntimeTopology({
302
+ runtimeMode: requestedRuntimeMode,
303
+ surfaceRole: input.surfaceRole,
304
+ appOrigin,
305
+ backendOrigin,
306
+ publicHost,
307
+ assetBasePath: input.assetBasePath,
308
+ secureTransport: input.secureTransport,
309
+ embedded: input.embedded,
310
+ embedParentOrigin: input.embedParentOrigin,
311
+ proxyStrategy,
312
+ ...input.socketOrigin ? { socketOrigin: input.socketOrigin } : {}
313
+ });
314
+ };
315
+ var isLocalDevControlSurfaceRuntimeMode = (runtimeMode) => LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES.has(
316
+ assertString(runtimeMode, "runtimeMode")
317
+ );
318
+ var isLocalDevControlSurfaceTopology = ({
319
+ runtimeMode
320
+ }) => isLocalDevControlSurfaceRuntimeMode(runtimeMode);
321
+ var parseRuntimeTopology = (serialized) => {
322
+ const normalized = assertString(
323
+ serialized,
324
+ "serialized runtime topology"
325
+ );
326
+ let parsed;
327
+ try {
328
+ parsed = JSON.parse(normalized);
329
+ } catch {
330
+ throw new Error("Runtime topology must be valid JSON.");
331
+ }
332
+ return resolveRuntimeTopology(parsed);
333
+ };
334
+ var readRuntimeTopologyFromEnv = (env2 = process.env) => {
335
+ for (const key of AIR_JAM_RUNTIME_TOPOLOGY_ENV_KEYS) {
336
+ const candidate = env2?.[key];
337
+ if (typeof candidate === "string" && candidate.trim().length > 0) {
338
+ return parseRuntimeTopology(candidate);
339
+ }
340
+ }
341
+ return null;
342
+ };
343
+ var readRuntimeTopologyFromWindow = (target = globalThis.window) => {
344
+ if (!target || typeof target !== "object") {
345
+ return null;
346
+ }
347
+ const candidate = target[AIR_JAM_RUNTIME_TOPOLOGY_WINDOW_KEY];
348
+ if (typeof candidate === "string" && candidate.trim().length > 0) {
349
+ return parseRuntimeTopology(candidate);
350
+ }
351
+ if (isObject(candidate)) {
352
+ return resolveRuntimeTopology(candidate);
353
+ }
354
+ return null;
355
+ };
356
+ var parseRuntimeTopologyFromSearchParams = (params) => {
357
+ if (!(params instanceof URLSearchParams)) {
358
+ throw new Error(
359
+ "Runtime topology search param reader expects URLSearchParams."
360
+ );
361
+ }
362
+ const hasAnyTopologyParam = REQUIRED_QUERY_KEYS.some(
363
+ (key) => params.has(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}${key}`)
364
+ );
365
+ if (!hasAnyTopologyParam) {
366
+ return null;
367
+ }
368
+ const missing = REQUIRED_QUERY_KEYS.filter(
369
+ (key) => !params.has(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}${key}`)
370
+ );
371
+ if (missing.length > 0) {
372
+ throw new Error(
373
+ `Runtime topology search params are incomplete. Missing: ${missing.join(", ")}.`
374
+ );
375
+ }
376
+ const embedParentOrigin = params.get(
377
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embed_parent_origin`
378
+ );
379
+ return resolveRuntimeTopology({
380
+ runtimeMode: params.get(
381
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}runtime_mode`
382
+ ),
383
+ surfaceRole: params.get(
384
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}surface_role`
385
+ ),
386
+ appOrigin: params.get(
387
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}app_origin`
388
+ ),
389
+ backendOrigin: params.get(
390
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}backend_origin`
391
+ ),
392
+ socketOrigin: params.get(
393
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}socket_origin`
394
+ ),
395
+ publicHost: params.get(
396
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}public_host`
397
+ ),
398
+ assetBasePath: params.get(
399
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}asset_base_path`
400
+ ),
401
+ secureTransport: fromBooleanParam(
402
+ params.get(
403
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}secure_transport`
404
+ ),
405
+ "secure_transport"
406
+ ),
407
+ embedded: fromBooleanParam(
408
+ params.get(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embedded`),
409
+ "embedded"
410
+ ),
411
+ proxyStrategy: params.get(
412
+ `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}proxy_strategy`
413
+ ),
414
+ ...embedParentOrigin ? { embedParentOrigin } : {}
415
+ });
416
+ };
417
+
86
418
  // src/context/air-jam-context.tsx
87
- var import_runtime_topology3 = require("@air-jam/runtime-topology");
88
419
  var import_react = require("react");
89
420
  var import_zustand2 = require("zustand");
90
421
  var import_shallow = require("zustand/react/shallow");
91
422
 
92
- // src/dev/browser-log-sink.ts
93
- var import_runtime_topology = require("@air-jam/runtime-topology");
94
-
95
423
  // src/diagnostics.ts
96
424
  var listeners = /* @__PURE__ */ new Set();
97
425
  var lastEmissionByKey = /* @__PURE__ */ new Map();
@@ -1125,7 +1453,7 @@ var ensureDevBrowserLogSink = (options) => {
1125
1453
  return;
1126
1454
  }
1127
1455
  const globalState = globalThis;
1128
- const autoEnabled = options.topology != null ? (0, import_runtime_topology.isLocalDevControlSurfaceTopology)(options.topology) : isDevelopmentRuntime();
1456
+ const autoEnabled = options.topology != null ? isLocalDevControlSurfaceTopology(options.topology) : isDevelopmentRuntime();
1129
1457
  if (!autoEnabled) {
1130
1458
  globalState.__airJamBrowserLogSink__?.dispose?.();
1131
1459
  delete globalState.__airJamBrowserLogSink__;
@@ -1325,9 +1653,6 @@ var InputManager = class {
1325
1653
  }
1326
1654
  };
1327
1655
 
1328
- // src/runtime/air-jam-config.ts
1329
- var import_runtime_topology2 = require("@air-jam/runtime-topology");
1330
-
1331
1656
  // src/constants.ts
1332
1657
  var DEFAULT_SERVER_PORT = 4e3;
1333
1658
  var CONTROLLER_PATH = "/controller";
@@ -1421,7 +1746,7 @@ var readRuntimeTopologyFromViteEnv = () => {
1421
1746
  if (!viteEnv?.VITE_AIR_JAM_RUNTIME_TOPOLOGY) {
1422
1747
  return null;
1423
1748
  }
1424
- return (0, import_runtime_topology2.readRuntimeTopologyFromEnv)({
1749
+ return readRuntimeTopologyFromEnv({
1425
1750
  VITE_AIR_JAM_RUNTIME_TOPOLOGY: viteEnv.VITE_AIR_JAM_RUNTIME_TOPOLOGY
1426
1751
  });
1427
1752
  };
@@ -1429,7 +1754,7 @@ var readRuntimeTopologyFromWindowSearchParams = () => {
1429
1754
  if (typeof window === "undefined") {
1430
1755
  return null;
1431
1756
  }
1432
- return (0, import_runtime_topology2.parseRuntimeTopologyFromSearchParams)(
1757
+ return parseRuntimeTopologyFromSearchParams(
1433
1758
  new URLSearchParams(window.location.search)
1434
1759
  );
1435
1760
  };
@@ -1437,7 +1762,7 @@ var applySurfaceRoleOverride = (topology, surfaceRole) => {
1437
1762
  if (!topology || !surfaceRole || topology.surfaceRole === surfaceRole) {
1438
1763
  return topology;
1439
1764
  }
1440
- return (0, import_runtime_topology2.resolveRuntimeTopology)({
1765
+ return resolveRuntimeTopology({
1441
1766
  ...topology,
1442
1767
  surfaceRole
1443
1768
  });
@@ -1454,7 +1779,7 @@ var resolveProjectTopologyFromEnv = (surfaceRole) => {
1454
1779
  }
1455
1780
  const secureTransport = appOrigin.startsWith("https://");
1456
1781
  const runtimeMode = isDevelopmentRuntime2() ? secureTransport ? "standalone-secure" : "standalone-dev" : "self-hosted-production";
1457
- return (0, import_runtime_topology2.resolveProjectRuntimeTopology)({
1782
+ return resolveProjectRuntimeTopology({
1458
1783
  runtimeMode,
1459
1784
  surfaceRole: effectiveSurfaceRole,
1460
1785
  appOrigin,
@@ -1472,8 +1797,8 @@ var resolveAirJamConfig = ({
1472
1797
  hostSessionKind = "game",
1473
1798
  resolveEnv = true
1474
1799
  }) => {
1475
- const resolvedTopology = topology ? applySurfaceRoleOverride((0, import_runtime_topology2.resolveRuntimeTopology)(topology), surfaceRole) : resolveEnv ? applySurfaceRoleOverride(
1476
- readRuntimeTopologyFromViteEnv() ?? (0, import_runtime_topology2.readRuntimeTopologyFromEnv)(getNodeEnv()) ?? (0, import_runtime_topology2.readRuntimeTopologyFromWindow)(window) ?? readRuntimeTopologyFromWindowSearchParams() ?? resolveProjectTopologyFromEnv(surfaceRole),
1800
+ const resolvedTopology = topology ? applySurfaceRoleOverride(resolveRuntimeTopology(topology), surfaceRole) : resolveEnv ? applySurfaceRoleOverride(
1801
+ readRuntimeTopologyFromViteEnv() ?? readRuntimeTopologyFromEnv(getNodeEnv()) ?? readRuntimeTopologyFromWindow(window) ?? readRuntimeTopologyFromWindowSearchParams() ?? resolveProjectTopologyFromEnv(surfaceRole),
1477
1802
  surfaceRole
1478
1803
  ) : null;
1479
1804
  if (!resolvedTopology) {
@@ -1850,7 +2175,7 @@ var AirJamProvider = ({
1850
2175
  ]
1851
2176
  );
1852
2177
  const localDevControlSurfacesEnabled = (0, import_react.useMemo)(
1853
- () => (0, import_runtime_topology3.isLocalDevControlSurfaceTopology)(config.topology),
2178
+ () => isLocalDevControlSurfaceTopology(config.topology),
1854
2179
  [config.topology]
1855
2180
  );
1856
2181
  const inputManager = (0, import_react.useMemo)(() => {
@@ -2221,7 +2546,7 @@ var parseAirJamBridgeInitMessage = (value) => {
2221
2546
  };
2222
2547
 
2223
2548
  // src/runtime/sdk-version.ts
2224
- var AIR_JAM_SDK_VERSION = true ? "0.9.0" : "0.0.0";
2549
+ var AIR_JAM_SDK_VERSION = true ? "0.9.2" : "0.0.0";
2225
2550
 
2226
2551
  // src/runtime/controller-bridge.ts
2227
2552
  var AIRJAM_CONTROLLER_BRIDGE_REQUEST = "AIRJAM_CONTROLLER_BRIDGE_REQUEST";
@@ -2371,9 +2696,6 @@ var parseControllerBridgeCloseMessage = (value) => {
2371
2696
  return result.success ? result.data : null;
2372
2697
  };
2373
2698
 
2374
- // src/runtime/runtime-session-params.ts
2375
- var import_runtime_topology4 = require("@air-jam/runtime-topology");
2376
-
2377
2699
  // src/store/air-jam-store-domain-constants.ts
2378
2700
  var AIR_JAM_DEFAULT_STORE_DOMAIN = "default";
2379
2701
  var AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN = "arcade.surface";
@@ -2446,7 +2768,7 @@ var resolveLegacyEmbeddedTopology = ({
2446
2768
  const embedParentOrigin = joinUrlOrigin ?? referrerOrigin ?? appOrigin;
2447
2769
  const publicHost = joinUrlOrigin ?? appOrigin;
2448
2770
  const secureTransport = appOrigin.startsWith("https://") && publicHost.startsWith("https://") && embedParentOrigin.startsWith("https://");
2449
- return (0, import_runtime_topology4.resolveRuntimeTopology)({
2771
+ return resolveRuntimeTopology({
2450
2772
  runtimeMode: "arcade-live",
2451
2773
  surfaceRole,
2452
2774
  appOrigin,
@@ -2474,7 +2796,7 @@ var readChildHostRuntimeParams = () => {
2474
2796
  const parsedCapabilityExpiresAt = rawCapabilityExpiresAt ? Number(rawCapabilityExpiresAt) : NaN;
2475
2797
  const joinUrl = params.get("aj_join_url");
2476
2798
  const normalizedJoinUrl = joinUrl ? normalizeRuntimeUrl(joinUrl) : null;
2477
- const topology = (0, import_runtime_topology4.parseRuntimeTopologyFromSearchParams)(params) ?? resolveLegacyEmbeddedTopology({
2799
+ const topology = parseRuntimeTopologyFromSearchParams(params) ?? resolveLegacyEmbeddedTopology({
2478
2800
  surfaceRole: "host",
2479
2801
  joinUrl: normalizedJoinUrl ?? void 0
2480
2802
  });
@@ -2504,7 +2826,7 @@ var readEmbeddedControllerRuntimeParams = () => {
2504
2826
  if (!room || !controllerId) {
2505
2827
  return null;
2506
2828
  }
2507
- const topology = (0, import_runtime_topology4.parseRuntimeTopologyFromSearchParams)(params) ?? resolveLegacyEmbeddedTopology({
2829
+ const topology = parseRuntimeTopologyFromSearchParams(params) ?? resolveLegacyEmbeddedTopology({
2508
2830
  surfaceRole: "controller"
2509
2831
  });
2510
2832
  if (!topology) {
@@ -4763,8 +5085,78 @@ var useHostTick = (options) => {
4763
5085
  }, [enabled, mode, tickIntervalMs, frameDeltaCapMs, frameStepCap]);
4764
5086
  };
4765
5087
 
4766
- // src/hooks/use-input-writer.ts
5088
+ // src/hooks/use-host-audio-mute-preference.ts
4767
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");
4768
5160
 
4769
5161
  // src/utils/is-rpc-serializable.ts
4770
5162
  var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
@@ -4811,7 +5203,7 @@ var isRpcSerializable = (value, seen = /* @__PURE__ */ new WeakSet()) => {
4811
5203
  var useInputWriter = () => {
4812
5204
  useAssertSessionScope("controller", "useInputWriter");
4813
5205
  const { store, getSocket } = useAirJamContext();
4814
- return (0, import_react13.useCallback)(
5206
+ return (0, import_react14.useCallback)(
4815
5207
  (input) => {
4816
5208
  if (typeof input !== "object" || input === null || Array.isArray(input)) {
4817
5209
  emitAirJamDiagnostic({
@@ -4897,11 +5289,11 @@ var useRoom = () => {
4897
5289
  };
4898
5290
 
4899
5291
  // src/hooks/use-send-signal.ts
4900
- var import_react14 = require("react");
5292
+ var import_react15 = require("react");
4901
5293
  var useSendSignal = () => {
4902
5294
  useAssertSessionScope("host", "useSendSignal");
4903
5295
  const { getSocket } = useAirJamContext();
4904
- const sendSignal = (0, import_react14.useCallback)(
5296
+ const sendSignal = (0, import_react15.useCallback)(
4905
5297
  (type, payload, targetId) => {
4906
5298
  const socket = getHostRealtimeClient((role) => getSocket(role));
4907
5299
  if (!socket || !socket.connected) {
@@ -4973,18 +5365,18 @@ var useHostRuntimeInspectionContract = () => createHostRuntimeInspectionContract
4973
5365
  var useControllerRuntimeInspectionContract = () => createControllerRuntimeInspectionContract(useAirJamController());
4974
5366
 
4975
5367
  // src/runtime/session-runtimes.tsx
4976
- var import_react18 = require("react");
5368
+ var import_react19 = require("react");
4977
5369
 
4978
5370
  // src/context/session-providers.tsx
4979
- var import_react15 = require("react");
5371
+ var import_react16 = require("react");
4980
5372
  var import_jsx_runtime4 = require("react/jsx-runtime");
4981
5373
  var createScopedSessionProvider = (scope) => {
4982
5374
  const ScopedSessionProvider = ({
4983
5375
  children,
4984
5376
  ...providerProps
4985
5377
  }) => {
4986
- const runtimeOwnersRef = (0, import_react15.useRef)(/* @__PURE__ */ new Map());
4987
- const claimOwner = (0, import_react15.useCallback)(
5378
+ const runtimeOwnersRef = (0, import_react16.useRef)(/* @__PURE__ */ new Map());
5379
+ const claimOwner = (0, import_react16.useCallback)(
4988
5380
  (kind, token, hookName) => {
4989
5381
  const existing = runtimeOwnersRef.current.get(kind);
4990
5382
  if (existing && existing.token !== token) {
@@ -5017,7 +5409,7 @@ var HostSessionProvider = createScopedSessionProvider("host");
5017
5409
  var ControllerSessionProvider = createScopedSessionProvider("controller");
5018
5410
 
5019
5411
  // src/hooks/internal/use-controller-runtime-api.ts
5020
- var import_react16 = require("react");
5412
+ var import_react17 = require("react");
5021
5413
  var import_zustand9 = require("zustand");
5022
5414
 
5023
5415
  // src/utils/ids.ts
@@ -5232,29 +5624,29 @@ var useControllerRuntimeApi = (options, hookName) => {
5232
5624
  useAssertSessionScope("controller", hookName);
5233
5625
  useClaimSessionRuntimeOwner("controller-runtime", hookName);
5234
5626
  const { store, getSocket, disconnectSocket } = useAirJamContext();
5235
- const nicknameRef = (0, import_react16.useRef)(options.nickname ?? "");
5236
- const avatarIdRef = (0, import_react16.useRef)(options.avatarId ?? "");
5237
- (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)(() => {
5238
5630
  nicknameRef.current = options.nickname ?? "";
5239
5631
  }, [options.nickname]);
5240
- (0, import_react16.useEffect)(() => {
5632
+ (0, import_react17.useEffect)(() => {
5241
5633
  avatarIdRef.current = options.avatarId ?? "";
5242
5634
  }, [options.avatarId]);
5243
- const embeddedController = (0, import_react16.useMemo)(
5635
+ const embeddedController = (0, import_react17.useMemo)(
5244
5636
  () => readEmbeddedControllerChildSession(),
5245
5637
  []
5246
5638
  );
5247
- const urlRoomId = (0, import_react16.useMemo)(() => getRoomFromLocation(), []);
5248
- const locationCapabilityToken = (0, import_react16.useMemo)(
5639
+ const urlRoomId = (0, import_react17.useMemo)(() => getRoomFromLocation(), []);
5640
+ const locationCapabilityToken = (0, import_react17.useMemo)(
5249
5641
  () => getControllerCapabilityTokenFromLocation(),
5250
5642
  []
5251
5643
  );
5252
5644
  const capabilityToken = options.capabilityToken === void 0 ? locationCapabilityToken : options.capabilityToken;
5253
- const previewDeviceId = (0, import_react16.useMemo)(
5645
+ const previewDeviceId = (0, import_react17.useMemo)(
5254
5646
  () => readPreviewControllerDeviceIdFromLocation(),
5255
5647
  []
5256
5648
  );
5257
- const joinSource = (0, import_react16.useMemo)(
5649
+ const joinSource = (0, import_react17.useMemo)(
5258
5650
  () => resolveControllerJoinSource({
5259
5651
  embeddedRoomId: embeddedController?.roomId,
5260
5652
  optionRoomId: options.roomId ?? null,
@@ -5262,7 +5654,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5262
5654
  }),
5263
5655
  [embeddedController?.roomId, options.roomId, urlRoomId]
5264
5656
  );
5265
- const parsedRoomId = (0, import_react16.useMemo)(() => {
5657
+ const parsedRoomId = (0, import_react17.useMemo)(() => {
5266
5658
  const code = embeddedController?.roomId ?? options.roomId ?? urlRoomId;
5267
5659
  if (!code) return null;
5268
5660
  try {
@@ -5271,7 +5663,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5271
5663
  return null;
5272
5664
  }
5273
5665
  }, [options.roomId, embeddedController, urlRoomId]);
5274
- const deviceId = (0, import_react16.useMemo)(() => {
5666
+ const deviceId = (0, import_react17.useMemo)(() => {
5275
5667
  if (embeddedController) {
5276
5668
  return null;
5277
5669
  }
@@ -5280,7 +5672,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5280
5672
  }
5281
5673
  return getOrCreateControllerDeviceId();
5282
5674
  }, [embeddedController, previewDeviceId]);
5283
- const controllerId = (0, import_react16.useMemo)(() => {
5675
+ const controllerId = (0, import_react17.useMemo)(() => {
5284
5676
  if (embeddedController?.controllerId) {
5285
5677
  return embeddedController.controllerId;
5286
5678
  }
@@ -5300,14 +5692,14 @@ var useControllerRuntimeApi = (options, hookName) => {
5300
5692
  }
5301
5693
  return generateControllerId();
5302
5694
  }, [options.controllerId, embeddedController, parsedRoomId]);
5303
- const onStateRef = (0, import_react16.useRef)(
5695
+ const onStateRef = (0, import_react17.useRef)(
5304
5696
  options.onState
5305
5697
  );
5306
- (0, import_react16.useEffect)(() => {
5698
+ (0, import_react17.useEffect)(() => {
5307
5699
  onStateRef.current = options.onState;
5308
5700
  }, [options.onState]);
5309
5701
  const activeControllerId = (0, import_zustand9.useStore)(store, (state) => state.controllerId);
5310
- (0, import_react16.useEffect)(() => {
5702
+ (0, import_react17.useEffect)(() => {
5311
5703
  updateDevBrowserLogContext({
5312
5704
  role: "controller",
5313
5705
  traceId: void 0,
@@ -5315,7 +5707,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5315
5707
  controllerId: activeControllerId ?? controllerId ?? void 0
5316
5708
  });
5317
5709
  }, [activeControllerId, controllerId, parsedRoomId]);
5318
- (0, import_react16.useEffect)(() => {
5710
+ (0, import_react17.useEffect)(() => {
5319
5711
  return () => {
5320
5712
  updateDevBrowserLogContext({
5321
5713
  role: void 0,
@@ -5324,9 +5716,9 @@ var useControllerRuntimeApi = (options, hookName) => {
5324
5716
  });
5325
5717
  };
5326
5718
  }, []);
5327
- const [reconnectKey, setReconnectKey] = (0, import_react16.useState)(0);
5328
- const leaveIssuedRef = (0, import_react16.useRef)(false);
5329
- 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)(
5330
5722
  ({
5331
5723
  event,
5332
5724
  level = "info",
@@ -5346,9 +5738,9 @@ var useControllerRuntimeApi = (options, hookName) => {
5346
5738
  },
5347
5739
  [controllerId]
5348
5740
  );
5349
- const lastObservedStateVersionRef = (0, import_react16.useRef)(null);
5350
- const emittedInvariantKeysRef = (0, import_react16.useRef)(/* @__PURE__ */ new Set());
5351
- 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)(
5352
5744
  ({
5353
5745
  code,
5354
5746
  roomId,
@@ -5373,11 +5765,11 @@ var useControllerRuntimeApi = (options, hookName) => {
5373
5765
  },
5374
5766
  [emitControllerRuntimeEvent]
5375
5767
  );
5376
- const socket = (0, import_react16.useMemo)(
5768
+ const socket = (0, import_react17.useMemo)(
5377
5769
  () => parsedRoomId ? getControllerRealtimeClient((role) => getSocket(role)) : null,
5378
5770
  [parsedRoomId, getSocket]
5379
5771
  );
5380
- const reconnect = (0, import_react16.useCallback)(() => {
5772
+ const reconnect = (0, import_react17.useCallback)(() => {
5381
5773
  if (!parsedRoomId) return;
5382
5774
  socket?.disconnect();
5383
5775
  if (!embeddedController) {
@@ -5385,7 +5777,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5385
5777
  }
5386
5778
  setReconnectKey((prev) => prev + 1);
5387
5779
  }, [parsedRoomId, disconnectSocket, socket, embeddedController]);
5388
- const leave = (0, import_react16.useCallback)(async () => {
5780
+ const leave = (0, import_react17.useCallback)(async () => {
5389
5781
  const storeState = store.getState();
5390
5782
  const activeControllerId2 = storeState.controllerId;
5391
5783
  if (!socket || !parsedRoomId || !activeControllerId2) {
@@ -5433,7 +5825,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5433
5825
  );
5434
5826
  });
5435
5827
  }, [embeddedController, parsedRoomId, socket, store]);
5436
- (0, import_react16.useEffect)(() => {
5828
+ (0, import_react17.useEffect)(() => {
5437
5829
  if (!socket) return;
5438
5830
  const handleSignal = (signal) => {
5439
5831
  if (signal.type !== "HAPTIC") return;
@@ -5469,7 +5861,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5469
5861
  socket.off("server:signal", handleSignal);
5470
5862
  };
5471
5863
  }, [socket]);
5472
- (0, import_react16.useEffect)(() => {
5864
+ (0, import_react17.useEffect)(() => {
5473
5865
  if (typeof window === "undefined" || !previewDeviceId || embeddedController || !socket) {
5474
5866
  return;
5475
5867
  }
@@ -5497,7 +5889,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5497
5889
  window.removeEventListener("message", handleMessage);
5498
5890
  };
5499
5891
  }, [disconnectSocket, embeddedController, leave, previewDeviceId, socket]);
5500
- (0, import_react16.useEffect)(() => {
5892
+ (0, import_react17.useEffect)(() => {
5501
5893
  if (!previewDeviceId || !parsedRoomId || embeddedController || !socket) {
5502
5894
  return;
5503
5895
  }
@@ -5518,7 +5910,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5518
5910
  );
5519
5911
  };
5520
5912
  }, [embeddedController, parsedRoomId, previewDeviceId, socket, store]);
5521
- (0, import_react16.useEffect)(() => {
5913
+ (0, import_react17.useEffect)(() => {
5522
5914
  const storeState = store.getState();
5523
5915
  storeState.setMode(detectRunMode());
5524
5916
  storeState.setRole("controller");
@@ -5810,13 +6202,13 @@ var useControllerRuntimeApi = (options, hookName) => {
5810
6202
  capabilityToken,
5811
6203
  emitInvariantOnce
5812
6204
  ]);
5813
- const setNickname = (0, import_react16.useCallback)((value) => {
6205
+ const setNickname = (0, import_react17.useCallback)((value) => {
5814
6206
  nicknameRef.current = value;
5815
6207
  }, []);
5816
- const setAvatarId = (0, import_react16.useCallback)((value) => {
6208
+ const setAvatarId = (0, import_react17.useCallback)((value) => {
5817
6209
  avatarIdRef.current = value;
5818
6210
  }, []);
5819
- const updatePlayerProfile = (0, import_react16.useCallback)(
6211
+ const updatePlayerProfile = (0, import_react17.useCallback)(
5820
6212
  (patch) => {
5821
6213
  const parsedPatch = playerProfilePatchSchema.safeParse(patch);
5822
6214
  if (!parsedPatch.success) {
@@ -5853,7 +6245,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5853
6245
  },
5854
6246
  [parsedRoomId, socket, store, embeddedController]
5855
6247
  );
5856
- const sendSystemCommand = (0, import_react16.useCallback)(
6248
+ const sendSystemCommand = (0, import_react17.useCallback)(
5857
6249
  (command) => {
5858
6250
  const storeState = store.getState();
5859
6251
  if (!parsedRoomId || !storeState.controllerId || !socket) return;
@@ -5868,7 +6260,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5868
6260
  },
5869
6261
  [parsedRoomId, socket, store]
5870
6262
  );
5871
- return (0, import_react16.useMemo)(
6263
+ return (0, import_react17.useMemo)(
5872
6264
  () => ({
5873
6265
  sendSystemCommand,
5874
6266
  setNickname,
@@ -5891,7 +6283,7 @@ var useControllerRuntimeApi = (options, hookName) => {
5891
6283
  };
5892
6284
 
5893
6285
  // src/hooks/internal/use-host-runtime-api.ts
5894
- var import_react17 = require("react");
6286
+ var import_react18 = require("react");
5895
6287
  var import_zod13 = require("zod");
5896
6288
  var import_zustand10 = require("zustand");
5897
6289
 
@@ -6122,10 +6514,10 @@ var useHostRuntimeApi = (options, hookName) => {
6122
6514
  useAssertSessionScope("host", hookName);
6123
6515
  useClaimSessionRuntimeOwner("host-runtime", hookName);
6124
6516
  const { config, store, getSocket, disconnectSocket, inputManager } = useAirJamContext();
6125
- const embeddedHost = (0, import_react17.useMemo)(() => readEmbeddedHostChildSession(), []);
6517
+ const embeddedHost = (0, import_react18.useMemo)(() => readEmbeddedHostChildSession(), []);
6126
6518
  const shouldConnect = true;
6127
6519
  const storeRoomId = (0, import_zustand10.useStore)(store, (s) => s.roomId);
6128
- const parsedRoomId = (0, import_react17.useMemo)(() => {
6520
+ const parsedRoomId = (0, import_react18.useMemo)(() => {
6129
6521
  if (embeddedHost) {
6130
6522
  return embeddedHost.roomId;
6131
6523
  }
@@ -6145,32 +6537,32 @@ var useHostRuntimeApi = (options, hookName) => {
6145
6537
  }
6146
6538
  return null;
6147
6539
  }, [options.roomId, storeRoomId, embeddedHost]);
6148
- const [controllerCapability, setControllerCapability] = (0, import_react17.useState)(null);
6149
- const joinUrlBuildKey = (0, import_react17.useMemo)(
6540
+ const [controllerCapability, setControllerCapability] = (0, import_react18.useState)(null);
6541
+ const joinUrlBuildKey = (0, import_react18.useMemo)(
6150
6542
  () => parsedRoomId ? `${parsedRoomId}\0${config.publicHost ?? ""}\0${controllerCapability?.token ?? ""}` : null,
6151
6543
  [config.publicHost, controllerCapability?.token, parsedRoomId]
6152
6544
  );
6153
- const [computedJoinUrl, setComputedJoinUrl] = (0, import_react17.useState)({
6545
+ const [computedJoinUrl, setComputedJoinUrl] = (0, import_react18.useState)({
6154
6546
  key: null,
6155
6547
  url: "",
6156
6548
  error: false
6157
6549
  });
6158
- const onPlayerJoinRef = (0, import_react17.useRef)(options.onPlayerJoin);
6159
- const onPlayerLeaveRef = (0, import_react17.useRef)(options.onPlayerLeave);
6160
- const parsedRoomIdRef = (0, import_react17.useRef)(parsedRoomId);
6161
- (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)(() => {
6162
6554
  onPlayerJoinRef.current = options.onPlayerJoin;
6163
6555
  onPlayerLeaveRef.current = options.onPlayerLeave;
6164
6556
  }, [options.onPlayerJoin, options.onPlayerLeave]);
6165
- (0, import_react17.useEffect)(() => {
6557
+ (0, import_react18.useEffect)(() => {
6166
6558
  parsedRoomIdRef.current = parsedRoomId;
6167
6559
  }, [parsedRoomId]);
6168
- const socket = (0, import_react17.useMemo)(
6560
+ const socket = (0, import_react18.useMemo)(
6169
6561
  () => shouldConnect ? getHostRealtimeClient((role) => getSocket(role)) : null,
6170
6562
  [shouldConnect, getSocket]
6171
6563
  );
6172
6564
  const setRegisteredRoomId = (0, import_zustand10.useStore)(store, (s) => s.setRegisteredRoomId);
6173
- const hydrateHostRoster = (0, import_react17.useCallback)(
6565
+ const hydrateHostRoster = (0, import_react18.useCallback)(
6174
6566
  (players, controllers) => {
6175
6567
  const latestState = store.getState();
6176
6568
  latestState.resetPlayers();
@@ -6184,7 +6576,7 @@ var useHostRuntimeApi = (options, hookName) => {
6184
6576
  },
6185
6577
  [store]
6186
6578
  );
6187
- const canEmitAuthoritativeHostState = (0, import_react17.useCallback)(
6579
+ const canEmitAuthoritativeHostState = (0, import_react18.useCallback)(
6188
6580
  (roomId) => {
6189
6581
  if (!socket || !socket.connected || !roomId) {
6190
6582
  return false;
@@ -6194,7 +6586,7 @@ var useHostRuntimeApi = (options, hookName) => {
6194
6586
  },
6195
6587
  [socket, store]
6196
6588
  );
6197
- const emitHostRuntimeEvent = (0, import_react17.useCallback)(
6589
+ const emitHostRuntimeEvent = (0, import_react18.useCallback)(
6198
6590
  ({
6199
6591
  event,
6200
6592
  level = "info",
@@ -6213,9 +6605,9 @@ var useHostRuntimeApi = (options, hookName) => {
6213
6605
  },
6214
6606
  []
6215
6607
  );
6216
- const lastObservedStateVersionRef = (0, import_react17.useRef)(null);
6217
- const emittedInvariantKeysRef = (0, import_react17.useRef)(/* @__PURE__ */ new Set());
6218
- 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)(
6219
6611
  ({
6220
6612
  code,
6221
6613
  roomId,
@@ -6240,7 +6632,7 @@ var useHostRuntimeApi = (options, hookName) => {
6240
6632
  },
6241
6633
  [emitHostRuntimeEvent]
6242
6634
  );
6243
- const sendState = (0, import_react17.useCallback)(
6635
+ const sendState = (0, import_react18.useCallback)(
6244
6636
  (state) => {
6245
6637
  const activeSocket = socket;
6246
6638
  const activeRoomId = parsedRoomIdRef.current;
@@ -6259,7 +6651,7 @@ var useHostRuntimeApi = (options, hookName) => {
6259
6651
  },
6260
6652
  [canEmitAuthoritativeHostState, socket]
6261
6653
  );
6262
- const setRuntimeState = (0, import_react17.useCallback)(
6654
+ const setRuntimeState = (0, import_react18.useCallback)(
6263
6655
  (runtimeState) => {
6264
6656
  const activeRoomId = parsedRoomIdRef.current;
6265
6657
  if (store.getState().runtimeState === runtimeState) {
@@ -6272,13 +6664,13 @@ var useHostRuntimeApi = (options, hookName) => {
6272
6664
  },
6273
6665
  [canEmitAuthoritativeHostState, sendState, store]
6274
6666
  );
6275
- const pauseRuntime = (0, import_react17.useCallback)(() => {
6667
+ const pauseRuntime = (0, import_react18.useCallback)(() => {
6276
6668
  setRuntimeState("paused");
6277
6669
  }, [setRuntimeState]);
6278
- const resumeRuntime = (0, import_react17.useCallback)(() => {
6670
+ const resumeRuntime = (0, import_react18.useCallback)(() => {
6279
6671
  setRuntimeState("playing");
6280
6672
  }, [setRuntimeState]);
6281
- const sendSignal = (0, import_react17.useCallback)(
6673
+ const sendSignal = (0, import_react18.useCallback)(
6282
6674
  (type, payload, targetId) => {
6283
6675
  if (!socket || !socket.connected) {
6284
6676
  return;
@@ -6292,7 +6684,7 @@ var useHostRuntimeApi = (options, hookName) => {
6292
6684
  },
6293
6685
  [socket]
6294
6686
  );
6295
- const reconnect = (0, import_react17.useCallback)(() => {
6687
+ const reconnect = (0, import_react18.useCallback)(() => {
6296
6688
  socket?.disconnect();
6297
6689
  if (!embeddedHost) {
6298
6690
  disconnectSocket("host");
@@ -6301,7 +6693,7 @@ var useHostRuntimeApi = (options, hookName) => {
6301
6693
  socket.connect();
6302
6694
  }
6303
6695
  }, [socket, embeddedHost, disconnectSocket]);
6304
- const removeController = (0, import_react17.useCallback)(
6696
+ const removeController = (0, import_react18.useCallback)(
6305
6697
  async (controllerId) => {
6306
6698
  const activeRoomId = parsedRoomIdRef.current;
6307
6699
  if (!socket || !activeRoomId) {
@@ -6318,7 +6710,7 @@ var useHostRuntimeApi = (options, hookName) => {
6318
6710
  },
6319
6711
  [socket]
6320
6712
  );
6321
- const resetRoom = (0, import_react17.useCallback)(async () => {
6713
+ const resetRoom = (0, import_react18.useCallback)(async () => {
6322
6714
  const activeRoomId = parsedRoomIdRef.current;
6323
6715
  if (!socket || !activeRoomId) {
6324
6716
  return {
@@ -6361,7 +6753,7 @@ var useHostRuntimeApi = (options, hookName) => {
6361
6753
  socket,
6362
6754
  store
6363
6755
  ]);
6364
- (0, import_react17.useEffect)(() => {
6756
+ (0, import_react18.useEffect)(() => {
6365
6757
  if (embeddedHost?.joinUrl) {
6366
6758
  return;
6367
6759
  }
@@ -6404,19 +6796,19 @@ var useHostRuntimeApi = (options, hookName) => {
6404
6796
  ]);
6405
6797
  const joinUrl = embeddedHost?.joinUrl ? embeddedHost.joinUrl : computedJoinUrl.key === joinUrlBuildKey ? computedJoinUrl.url : "";
6406
6798
  const joinUrlStatus = embeddedHost?.joinUrl ? "ready" : !joinUrlBuildKey ? "loading" : computedJoinUrl.key !== joinUrlBuildKey ? "loading" : computedJoinUrl.error ? "unavailable" : computedJoinUrl.url ? "ready" : "loading";
6407
- const reconnectRetryTimeoutRef = (0, import_react17.useRef)(
6799
+ const reconnectRetryTimeoutRef = (0, import_react18.useRef)(
6408
6800
  null
6409
6801
  );
6410
- const setDevHostTraceId = (0, import_react17.useCallback)((traceId) => {
6802
+ const setDevHostTraceId = (0, import_react18.useCallback)((traceId) => {
6411
6803
  updateDevBrowserLogContext({ traceId });
6412
6804
  }, []);
6413
- (0, import_react17.useEffect)(() => {
6805
+ (0, import_react18.useEffect)(() => {
6414
6806
  updateDevBrowserLogContext({
6415
6807
  role: "host",
6416
6808
  roomId: parsedRoomId ?? void 0
6417
6809
  });
6418
6810
  }, [parsedRoomId]);
6419
- (0, import_react17.useEffect)(() => {
6811
+ (0, import_react18.useEffect)(() => {
6420
6812
  return () => {
6421
6813
  updateDevBrowserLogContext({
6422
6814
  role: void 0,
@@ -6425,13 +6817,13 @@ var useHostRuntimeApi = (options, hookName) => {
6425
6817
  });
6426
6818
  };
6427
6819
  }, []);
6428
- const hostGrantResponseSchema = (0, import_react17.useMemo)(
6820
+ const hostGrantResponseSchema = (0, import_react18.useMemo)(
6429
6821
  () => import_zod13.z.object({
6430
6822
  hostGrant: import_zod13.z.string().min(1)
6431
6823
  }),
6432
6824
  []
6433
6825
  );
6434
- (0, import_react17.useEffect)(() => {
6826
+ (0, import_react18.useEffect)(() => {
6435
6827
  const storeState = store.getState();
6436
6828
  const initialRoomId = parsedRoomIdRef.current;
6437
6829
  storeState.setMode(detectRunMode());
@@ -6905,7 +7297,7 @@ var useHostRuntimeApi = (options, hookName) => {
6905
7297
  emitInvariantOnce,
6906
7298
  hydrateHostRoster
6907
7299
  ]);
6908
- const getInput = (0, import_react17.useCallback)(
7300
+ const getInput = (0, import_react18.useCallback)(
6909
7301
  (controllerId) => {
6910
7302
  if (!inputManager) {
6911
7303
  return void 0;
@@ -6914,7 +7306,7 @@ var useHostRuntimeApi = (options, hookName) => {
6914
7306
  },
6915
7307
  [inputManager]
6916
7308
  );
6917
- return (0, import_react17.useMemo)(
7309
+ return (0, import_react18.useMemo)(
6918
7310
  () => ({
6919
7311
  roomId: parsedRoomId ?? "",
6920
7312
  joinUrl,
@@ -6953,7 +7345,7 @@ var useHostRuntimeApi = (options, hookName) => {
6953
7345
  var import_jsx_runtime5 = require("react/jsx-runtime");
6954
7346
  var HostRuntimeInspectionPublisher = () => {
6955
7347
  const inspection = useHostRuntimeInspectionContract();
6956
- (0, import_react18.useEffect)(() => {
7348
+ (0, import_react19.useEffect)(() => {
6957
7349
  if (typeof window === "undefined") {
6958
7350
  return;
6959
7351
  }
@@ -6968,7 +7360,7 @@ var HostRuntimeInspectionPublisher = () => {
6968
7360
  };
6969
7361
  var ControllerRuntimeInspectionPublisher = () => {
6970
7362
  const inspection = useControllerRuntimeInspectionContract();
6971
- (0, import_react18.useEffect)(() => {
7363
+ (0, import_react19.useEffect)(() => {
6972
7364
  if (typeof window === "undefined") {
6973
7365
  return;
6974
7366
  }
@@ -7091,7 +7483,7 @@ var toShellMatchPhase = (phase) => {
7091
7483
 
7092
7484
  // src/runtime/air-jam-error-boundary.tsx
7093
7485
  var import_lucide_react = require("lucide-react");
7094
- var import_react19 = require("react");
7486
+ var import_react20 = require("react");
7095
7487
  var import_jsx_runtime6 = require("react/jsx-runtime");
7096
7488
  var toError = (value) => {
7097
7489
  if (value instanceof Error) {
@@ -7191,19 +7583,19 @@ var DefaultFallback = ({
7191
7583
  isEmbedded
7192
7584
  }) => {
7193
7585
  const digest = createErrorDigest(error);
7194
- const [isMinimized, setIsMinimized] = (0, import_react19.useState)(false);
7195
- const [copyState, setCopyState] = (0, import_react19.useState)(
7586
+ const [isMinimized, setIsMinimized] = (0, import_react20.useState)(false);
7587
+ const [copyState, setCopyState] = (0, import_react20.useState)(
7196
7588
  "idle"
7197
7589
  );
7198
- const copyResetTimeoutRef = (0, import_react19.useRef)(null);
7199
- (0, import_react19.useEffect)(() => {
7590
+ const copyResetTimeoutRef = (0, import_react20.useRef)(null);
7591
+ (0, import_react20.useEffect)(() => {
7200
7592
  return () => {
7201
7593
  if (copyResetTimeoutRef.current !== null && typeof window !== "undefined") {
7202
7594
  window.clearTimeout(copyResetTimeoutRef.current);
7203
7595
  }
7204
7596
  };
7205
7597
  }, []);
7206
- const scheduleCopyStatusReset = (0, import_react19.useCallback)(() => {
7598
+ const scheduleCopyStatusReset = (0, import_react20.useCallback)(() => {
7207
7599
  if (typeof window === "undefined") {
7208
7600
  return;
7209
7601
  }
@@ -7215,7 +7607,7 @@ var DefaultFallback = ({
7215
7607
  copyResetTimeoutRef.current = null;
7216
7608
  }, 1800);
7217
7609
  }, []);
7218
- const handleCopy = (0, import_react19.useCallback)(async () => {
7610
+ const handleCopy = (0, import_react20.useCallback)(async () => {
7219
7611
  try {
7220
7612
  await copyTextToClipboard(
7221
7613
  createCopyPayload({
@@ -7643,7 +8035,7 @@ var DefaultFallback = ({
7643
8035
  }
7644
8036
  );
7645
8037
  };
7646
- var AirJamErrorBoundary = class extends import_react19.Component {
8038
+ var AirJamErrorBoundary = class extends import_react20.Component {
7647
8039
  state = {
7648
8040
  error: null
7649
8041
  };
@@ -7715,7 +8107,6 @@ var AirJamErrorBoundary = class extends import_react19.Component {
7715
8107
  };
7716
8108
 
7717
8109
  // src/runtime/create-air-jam-app.tsx
7718
- var import_runtime_topology5 = require("@air-jam/runtime-topology");
7719
8110
  var import_jsx_runtime7 = require("react/jsx-runtime");
7720
8111
  var import_meta3 = {};
7721
8112
  var resolveControllerPath = (controllerPath) => {
@@ -7761,7 +8152,7 @@ var env = {
7761
8152
  const explicitTopology = viteEnv?.VITE_AIR_JAM_RUNTIME_TOPOLOGY ? JSON.parse(
7762
8153
  viteEnv.VITE_AIR_JAM_RUNTIME_TOPOLOGY
7763
8154
  ) : null;
7764
- const projectTopology = !explicitTopology && viteEnv?.VITE_AIR_JAM_PUBLIC_HOST ? (0, import_runtime_topology5.resolveProjectRuntimeTopology)({
8155
+ const projectTopology = !explicitTopology && viteEnv?.VITE_AIR_JAM_PUBLIC_HOST ? resolveProjectRuntimeTopology({
7765
8156
  runtimeMode: viteEnv.DEV ? viteEnv.VITE_AIR_JAM_PUBLIC_HOST.startsWith("https://") ? "standalone-secure" : "standalone-dev" : "self-hosted-production",
7766
8157
  surfaceRole: "host",
7767
8158
  appOrigin: viteEnv.VITE_AIR_JAM_PUBLIC_HOST,
@@ -8029,7 +8420,7 @@ var agentAction = {
8029
8420
  var defineAirJamAgentContract = (contract) => contract;
8030
8421
 
8031
8422
  // src/store/create-air-jam-store.ts
8032
- var import_react20 = require("react");
8423
+ var import_react21 = require("react");
8033
8424
  var import_zustand11 = require("zustand");
8034
8425
  var INTERNAL_ACTION_PREFIX = "_";
8035
8426
  var UNRESOLVED_ACTOR_ID = "unknown";
@@ -8557,11 +8948,11 @@ function createAirJamStore2(initializer, options) {
8557
8948
  );
8558
8949
  const blockArcadeShellHostBroadcast = resolvedStoreDomain === AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN && hostArcadeRestore.phase !== "idle";
8559
8950
  const canBroadcastHostState = role === "host" && !!roomId && registeredRoomId === roomId && !blockArcadeShellHostBroadcast;
8560
- const connectedPlayerIds = (0, import_react20.useMemo)(
8951
+ const connectedPlayerIds = (0, import_react21.useMemo)(
8561
8952
  () => Array.from(new Set(players.map((player) => player.id))).sort(),
8562
8953
  [players]
8563
8954
  );
8564
- const playerRosterKey = (0, import_react20.useMemo)(
8955
+ const playerRosterKey = (0, import_react21.useMemo)(
8565
8956
  () => players.map((player) => player.id).sort().join(","),
8566
8957
  [players]
8567
8958
  );
@@ -8582,7 +8973,7 @@ function createAirJamStore2(initializer, options) {
8582
8973
  socket.id ?? "socket",
8583
8974
  role === "controller" ? connectionStatus : "host"
8584
8975
  ].join(":") : null;
8585
- (0, import_react20.useEffect)(() => {
8976
+ (0, import_react21.useEffect)(() => {
8586
8977
  if (!runtimeBindingKey || !socket || !roomId || !role) {
8587
8978
  return;
8588
8979
  }
@@ -8617,7 +9008,7 @@ function createAirJamStore2(initializer, options) {
8617
9008
  socket?.id,
8618
9009
  resolvedStoreDomain
8619
9010
  ]);
8620
- (0, import_react20.useEffect)(() => {
9011
+ (0, import_react21.useEffect)(() => {
8621
9012
  if (!runtimeBindingKey || role !== "host" || !canBroadcastHostState || !roomId) {
8622
9013
  return;
8623
9014
  }
@@ -8648,7 +9039,7 @@ function createAirJamStore2(initializer, options) {
8648
9039
  canBroadcastHostState,
8649
9040
  runtimeBindingKey
8650
9041
  ]);
8651
- const dispatchedActions = (0, import_react20.useMemo)(
9042
+ const dispatchedActions = (0, import_react21.useMemo)(
8652
9043
  () => createDispatchedActions({ kind: "default" }),
8653
9044
  []
8654
9045
  );
@@ -8683,13 +9074,13 @@ function createAirJamStore2(initializer, options) {
8683
9074
  };
8684
9075
  };
8685
9076
  const useHostActionListener = (listener, options2) => {
8686
- const listenerRef = (0, import_react20.useRef)(listener);
8687
- (0, import_react20.useEffect)(() => {
9077
+ const listenerRef = (0, import_react21.useRef)(listener);
9078
+ (0, import_react21.useEffect)(() => {
8688
9079
  listenerRef.current = listener;
8689
9080
  }, [listener]);
8690
9081
  const includeRejected = options2?.includeRejected ?? false;
8691
9082
  const actionNamesKey = options2?.actionNames?.join("\0") ?? "";
8692
- (0, import_react20.useEffect)(() => {
9083
+ (0, import_react21.useEffect)(() => {
8693
9084
  return subscribeHostActions((event) => {
8694
9085
  listenerRef.current(event);
8695
9086
  }, options2);
@@ -8697,8 +9088,8 @@ function createAirJamStore2(initializer, options) {
8697
9088
  };
8698
9089
  const useLiveStateRef = () => {
8699
9090
  const latestState = useSyncedStore((state) => state);
8700
- const stateRef = (0, import_react20.useRef)(latestState);
8701
- (0, import_react20.useEffect)(() => {
9091
+ const stateRef = (0, import_react21.useRef)(latestState);
9092
+ (0, import_react21.useEffect)(() => {
8702
9093
  stateRef.current = latestState;
8703
9094
  }, [latestState]);
8704
9095
  return stateRef;
@@ -8760,6 +9151,7 @@ function createAirJamStore2(initializer, options) {
8760
9151
  useControllerTick,
8761
9152
  useControllerToasts,
8762
9153
  useGetInput,
9154
+ useHostAudioMutePreference,
8763
9155
  useHostRuntimeInspectionContract,
8764
9156
  useHostTick,
8765
9157
  useInheritedPlatformSettings,