@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/ui.d.cts CHANGED
@@ -55,16 +55,26 @@ declare function HostMuteButton({ muted, onToggle, className, labelClassName, mu
55
55
  interface JoinQrOverlayProps {
56
56
  open: boolean;
57
57
  value: string | null | undefined;
58
+ status?: "ready" | "loading" | "unavailable";
58
59
  roomId?: string | null;
59
60
  onClose?: () => void;
60
61
  title?: string;
62
+ roomLabel?: string;
61
63
  description?: string;
64
+ unavailableLabel?: string;
65
+ loadingLabel?: string;
66
+ qrAlt?: string;
67
+ showCloseButton?: boolean;
62
68
  className?: string;
63
69
  panelClassName?: string;
64
70
  qrClassName?: string;
71
+ bodyClassName?: string;
72
+ messageClassName?: string;
73
+ descriptionClassName?: string;
74
+ closeButtonClassName?: string;
65
75
  size?: number;
66
76
  }
67
- declare const JoinQrOverlay: ({ open, value, roomId, onClose, title, description, className, panelClassName, qrClassName, size, }: JoinQrOverlayProps) => JSX.Element | null;
77
+ declare const JoinQrOverlay: ({ open, value, status, roomId, onClose, title, roomLabel, description, unavailableLabel, loadingLabel, qrAlt, showCloseButton, className, panelClassName, qrClassName, bodyClassName, messageClassName, descriptionClassName, closeButtonClassName, size, }: JoinQrOverlayProps) => JSX.Element | null;
68
78
 
69
79
  interface JoinUrlActionButtonsProps {
70
80
  hasValue: boolean;
package/dist/ui.d.ts CHANGED
@@ -55,16 +55,26 @@ declare function HostMuteButton({ muted, onToggle, className, labelClassName, mu
55
55
  interface JoinQrOverlayProps {
56
56
  open: boolean;
57
57
  value: string | null | undefined;
58
+ status?: "ready" | "loading" | "unavailable";
58
59
  roomId?: string | null;
59
60
  onClose?: () => void;
60
61
  title?: string;
62
+ roomLabel?: string;
61
63
  description?: string;
64
+ unavailableLabel?: string;
65
+ loadingLabel?: string;
66
+ qrAlt?: string;
67
+ showCloseButton?: boolean;
62
68
  className?: string;
63
69
  panelClassName?: string;
64
70
  qrClassName?: string;
71
+ bodyClassName?: string;
72
+ messageClassName?: string;
73
+ descriptionClassName?: string;
74
+ closeButtonClassName?: string;
65
75
  size?: number;
66
76
  }
67
- declare const JoinQrOverlay: ({ open, value, roomId, onClose, title, description, className, panelClassName, qrClassName, size, }: JoinQrOverlayProps) => JSX.Element | null;
77
+ declare const JoinQrOverlay: ({ open, value, status, roomId, onClose, title, roomLabel, description, unavailableLabel, loadingLabel, qrAlt, showCloseButton, className, panelClassName, qrClassName, bodyClassName, messageClassName, descriptionClassName, closeButtonClassName, size, }: JoinQrOverlayProps) => JSX.Element | null;
68
78
 
69
79
  interface JoinUrlActionButtonsProps {
70
80
  hasValue: boolean;
package/dist/ui.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  readEmbeddedControllerRuntimeParams,
3
3
  useAirJamController
4
- } from "./chunk-VDRNNGHX.js";
4
+ } from "./chunk-CVYR5RJT.js";
5
5
  import {
6
6
  createControllerPresentationSyncMessage
7
- } from "./chunk-MKBASO6X.js";
7
+ } from "./chunk-KOB73SPD.js";
8
8
  import "./chunk-X24K52DG.js";
9
9
  import {
10
10
  Button,
@@ -15,23 +15,23 @@ import {
15
15
  shellHeaderClassName,
16
16
  shellHelperTextClassName,
17
17
  shellLabelClassName,
18
- shellPanelClassName,
19
18
  shellUtilityButtonClassName
20
19
  } from "./chunk-EVZJA6RN.js";
21
20
  import {
22
21
  usePlatformAudioSettings
23
- } from "./chunk-D3X4MN4U.js";
24
- import "./chunk-Y4RAPKKB.js";
22
+ } from "./chunk-Q4UALQO4.js";
23
+ import "./chunk-7OTQTT6H.js";
24
+ import "./chunk-DY67S3LR.js";
25
25
  import {
26
26
  useSessionScope
27
- } from "./chunk-HFWRZVZ3.js";
27
+ } from "./chunk-NUJBMV3O.js";
28
28
  import "./chunk-LIXPF4P6.js";
29
- import "./chunk-W2VK36RO.js";
30
- import "./chunk-BE6Z4SIT.js";
31
- import "./chunk-CQUG24WX.js";
32
29
  import "./chunk-ZLPL2R3R.js";
33
30
  import "./chunk-32NYL7XI.js";
31
+ import "./chunk-W2VK36RO.js";
32
+ import "./chunk-UWJOIVON.js";
34
33
  import "./chunk-3USU7GY2.js";
34
+ import "./chunk-BE6Z4SIT.js";
35
35
 
36
36
  // src/components/connection-status-pill.tsx
37
37
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -265,7 +265,8 @@ function HostMuteButton({
265
265
  }
266
266
 
267
267
  // src/components/join-qr-overlay.tsx
268
- import { useEffect as useEffect3 } from "react";
268
+ import { useEffect as useEffect3, useState as useState3 } from "react";
269
+ import { createPortal } from "react-dom";
269
270
 
270
271
  // src/components/room-qr-code.tsx
271
272
  import { toDataURL } from "qrcode";
@@ -367,17 +368,29 @@ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
367
368
  var JoinQrOverlay = ({
368
369
  open,
369
370
  value,
371
+ status = "ready",
370
372
  roomId,
371
373
  onClose,
372
- title = "Scan to join",
374
+ title = "Scan QR code to join as a controller",
375
+ roomLabel = "Join room",
373
376
  description = "Scan with your phone to connect as a controller.",
377
+ unavailableLabel = "Join URL unavailable right now.",
378
+ loadingLabel = "Preparing join QR\u2026",
379
+ qrAlt,
380
+ showCloseButton = false,
374
381
  className,
375
382
  panelClassName,
376
383
  qrClassName,
377
- size = 440
384
+ bodyClassName,
385
+ messageClassName,
386
+ descriptionClassName,
387
+ closeButtonClassName,
388
+ size = 260
378
389
  }) => {
379
390
  const joinUrlValue = value?.trim() ?? "";
380
- const hasJoinUrl = joinUrlValue.length > 0;
391
+ const effectiveStatus = status === "ready" && joinUrlValue.length === 0 ? "unavailable" : status;
392
+ const overlaySize = `min(72vw, ${size}px)`;
393
+ const [entered, setEntered] = useState3(false);
381
394
  useEffect3(() => {
382
395
  if (!open || typeof window === "undefined") {
383
396
  return;
@@ -392,20 +405,34 @@ var JoinQrOverlay = ({
392
405
  window.removeEventListener("keydown", handleKeyDown);
393
406
  };
394
407
  }, [onClose, open]);
408
+ useEffect3(() => {
409
+ if (!open || typeof window === "undefined") {
410
+ setEntered(false);
411
+ return;
412
+ }
413
+ setEntered(false);
414
+ const frame = window.requestAnimationFrame(() => {
415
+ setEntered(true);
416
+ });
417
+ return () => {
418
+ window.cancelAnimationFrame(frame);
419
+ };
420
+ }, [open]);
395
421
  if (!open) {
396
422
  return null;
397
423
  }
398
424
  const handlePanelClick = (event) => {
399
425
  event.stopPropagation();
400
426
  };
401
- return /* @__PURE__ */ jsx6(
427
+ const dialog = /* @__PURE__ */ jsx6(
402
428
  "div",
403
429
  {
404
430
  role: "dialog",
405
431
  "aria-modal": "true",
406
432
  "aria-label": roomId ? `Join room ${roomId}` : title,
407
433
  className: cn(
408
- "absolute inset-0 z-50 flex items-center justify-center bg-black/82 px-6 py-8 backdrop-blur-md",
434
+ "pointer-events-auto fixed inset-0 z-[120] flex cursor-pointer flex-col items-center justify-center bg-black/85 px-6 backdrop-blur-md transition-opacity duration-200 ease-out",
435
+ entered ? "opacity-100" : "opacity-0",
409
436
  className
410
437
  ),
411
438
  onClick: onClose,
@@ -413,17 +440,34 @@ var JoinQrOverlay = ({
413
440
  "div",
414
441
  {
415
442
  className: cn(
416
- "flex w-full max-w-xl flex-col items-center gap-6 px-6 py-7 text-center",
417
- shellPanelClassName,
443
+ "flex cursor-default flex-col items-center gap-6 text-center transition-transform duration-200 ease-out",
444
+ entered ? "translate-y-0" : "-translate-y-4",
418
445
  panelClassName
419
446
  ),
420
447
  onClick: handlePanelClick,
421
448
  children: [
422
449
  /* @__PURE__ */ jsxs6("div", { className: "space-y-1", children: [
423
- /* @__PURE__ */ jsx6("p", { className: "text-[0.6875rem] font-semibold tracking-[0.22em] text-white/52 uppercase", children: title }),
424
- roomId ? /* @__PURE__ */ jsx6("p", { className: "text-3xl font-semibold tracking-[0.12em] text-white uppercase tabular-nums", children: roomId }) : null
450
+ /* @__PURE__ */ jsx6("p", { className: "text-[11px] tracking-[0.18em] text-slate-400 uppercase", children: roomLabel }),
451
+ roomId ? /* @__PURE__ */ jsx6("p", { className: "text-2xl font-semibold tracking-tight text-white tabular-nums", children: roomId }) : null
425
452
  ] }),
426
- hasJoinUrl ? /* @__PURE__ */ jsx6(
453
+ effectiveStatus === "loading" ? /* @__PURE__ */ jsxs6(
454
+ "div",
455
+ {
456
+ className: cn(
457
+ "flex flex-col items-center justify-center gap-3 rounded-lg border border-white/25 bg-white/6 px-5 py-10 text-sm text-white/70 shadow-sm",
458
+ bodyClassName
459
+ ),
460
+ style: {
461
+ width: overlaySize,
462
+ height: "auto",
463
+ aspectRatio: "1 / 1"
464
+ },
465
+ children: [
466
+ /* @__PURE__ */ jsx6("span", { className: "h-8 w-8 animate-spin rounded-full border-2 border-white/15 border-t-white/85" }),
467
+ /* @__PURE__ */ jsx6("span", { children: loadingLabel })
468
+ ]
469
+ }
470
+ ) : effectiveStatus === "ready" ? /* @__PURE__ */ jsx6(
427
471
  RoomQrCode,
428
472
  {
429
473
  value: joinUrlValue,
@@ -431,31 +475,65 @@ var JoinQrOverlay = ({
431
475
  padding: 2,
432
476
  foregroundColor: "#111827",
433
477
  backgroundColor: "#ffffff",
434
- className: cn("rounded-xl bg-white shadow-sm", qrClassName),
478
+ className: cn(
479
+ "rounded-lg border border-white/25 bg-white/6 shadow-sm",
480
+ qrClassName
481
+ ),
435
482
  style: {
436
- width: "min(72vw, 26rem)",
483
+ width: overlaySize,
437
484
  height: "auto",
438
485
  aspectRatio: "1 / 1"
439
486
  },
440
- alt: roomId ? `QR code to join room ${roomId}` : "QR code to join as a controller"
487
+ alt: qrAlt ?? (roomId ? `QR code to join room ${roomId}` : "QR code to join as a controller")
441
488
  }
442
- ) : /* @__PURE__ */ jsx6("div", { className: "flex w-full max-w-[26rem] items-center justify-center rounded-xl border border-white/12 bg-white/6 px-5 py-10 text-sm leading-6 text-white/68", children: "Join URL unavailable right now." }),
443
- /* @__PURE__ */ jsx6("p", { className: "max-w-md text-sm leading-6 text-white/68", children: description }),
489
+ ) : /* @__PURE__ */ jsx6(
490
+ "div",
491
+ {
492
+ className: cn(
493
+ "flex items-center justify-center rounded-lg border border-white/25 bg-white/6 px-5 py-10 text-sm text-white/70 shadow-sm",
494
+ messageClassName
495
+ ),
496
+ style: {
497
+ width: overlaySize,
498
+ height: "auto",
499
+ aspectRatio: "1 / 1"
500
+ },
501
+ children: unavailableLabel
502
+ }
503
+ ),
444
504
  /* @__PURE__ */ jsx6(
505
+ "p",
506
+ {
507
+ className: cn(
508
+ "max-w-xs text-center text-sm text-slate-400",
509
+ descriptionClassName
510
+ ),
511
+ children: description
512
+ }
513
+ ),
514
+ showCloseButton ? /* @__PURE__ */ jsx6(
445
515
  Button,
446
516
  {
447
517
  type: "button",
448
518
  variant: "outline",
449
519
  onClick: onClose,
450
- className: cn("rounded-2xl px-5", shellUtilityButtonClassName),
520
+ className: cn(
521
+ "rounded-2xl px-5",
522
+ shellUtilityButtonClassName,
523
+ closeButtonClassName
524
+ ),
451
525
  children: "Close"
452
526
  }
453
- )
527
+ ) : null
454
528
  ]
455
529
  }
456
530
  )
457
531
  }
458
532
  );
533
+ if (typeof document === "undefined") {
534
+ return dialog;
535
+ }
536
+ return createPortal(dialog, document.body);
459
537
  };
460
538
 
461
539
  // src/components/join-url-action-buttons.tsx
@@ -933,7 +1011,7 @@ var RuntimeShellHeader = ({
933
1011
  };
934
1012
 
935
1013
  // src/components/surface-viewport.tsx
936
- import { useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState3 } from "react";
1014
+ import { useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState4 } from "react";
937
1015
 
938
1016
  // src/runtime/controller-presentation.ts
939
1017
  var publishEmbeddedControllerPresentation = (orientation) => {
@@ -1261,7 +1339,7 @@ var SurfaceViewport = ({
1261
1339
  minScale,
1262
1340
  maxScale
1263
1341
  }) => {
1264
- const [viewport, setViewport] = useState3(null);
1342
+ const [viewport, setViewport] = useState4(null);
1265
1343
  const viewportRef = useRef2(null);
1266
1344
  const sessionScope = useSessionScope();
1267
1345
  useEffect4(() => {
@@ -1583,7 +1661,7 @@ var useControllerShellStatus = ({
1583
1661
  };
1584
1662
 
1585
1663
  // src/hooks/use-host-join-controls.ts
1586
- import { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
1664
+ import { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo2, useRef as useRef3, useState as useState5 } from "react";
1587
1665
  var copyTextToClipboard = async (text) => {
1588
1666
  if (!text) {
1589
1667
  return false;
@@ -1618,8 +1696,8 @@ var useHostJoinControls = ({
1618
1696
  onStartMatch,
1619
1697
  copiedDurationMs = 1800
1620
1698
  }) => {
1621
- const [copied, setCopied] = useState4(false);
1622
- const [joinQrVisible, setJoinQrVisible] = useState4(false);
1699
+ const [copied, setCopied] = useState5(false);
1700
+ const [joinQrVisible, setJoinQrVisible] = useState5(false);
1623
1701
  const resetTimerRef = useRef3(null);
1624
1702
  const joinUrlValue = useMemo2(() => joinUrl ?? "", [joinUrl]);
1625
1703
  const hasJoinUrl = joinUrlValue.length > 0;