@q9labsai/chalk-react 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -30
- package/dist/Board-PPO62QTR.js +80 -0
- package/dist/CallCharts-7ZQLN47C.js +114 -0
- package/dist/CallDetails-IG57GXT2.js +200 -0
- package/dist/CallDialogContent-GST2I23W.js +177 -0
- package/dist/CameraBackgroundPicker-AZXKBGRF.js +72 -0
- package/dist/ConnectionNotice-NQUBBT46.js +55 -0
- package/dist/DeviceAccessCard-MLRBTPRP.js +238 -0
- package/dist/DeviceAccessWaiting-MQXXW45M.js +25 -0
- package/dist/DeviceSheet-GZTV44UW.js +118 -0
- package/dist/InviteQrCode-TNTZA3GS.js +54 -0
- package/dist/KnockNotice-CAW4CJ4S.js +181 -0
- package/dist/ReactionSheet-ZU6RWC66.js +132 -0
- package/dist/chunk-26PBFST5.js +25 -0
- package/dist/{chunk-K5DV2OTY.js → chunk-4RSCAIFK.js} +340 -165
- package/dist/chunk-ADIDI7AJ.js +10 -0
- package/dist/chunk-ALGD3RBI.js +10 -0
- package/dist/chunk-CQBYFA2W.js +73 -0
- package/dist/chunk-E6HPIMFO.js +44 -0
- package/dist/{chunk-LYZ7EBFF.js → chunk-F6QZY5SM.js} +4116 -4605
- package/dist/chunk-I6FSUWKG.js +51 -0
- package/dist/chunk-JDCFKSGV.js +95 -0
- package/dist/chunk-PH3RC6T6.js +476 -0
- package/dist/chunk-PMGIER77.js +92 -0
- package/dist/chunk-Q36UO2T2.js +363 -0
- package/dist/chunk-SBGC5DKV.js +114 -0
- package/dist/chunk-SZNV3J4B.js +9 -0
- package/dist/{chunk-4U7QZC72.js → chunk-TSBY6C5U.js} +1 -102
- package/dist/chunk-XY7WXXME.js +85 -0
- package/dist/chunk-YOWY22N7.js +148 -0
- package/dist/chunk-Z5AASN4L.js +34 -0
- package/dist/components/admission-panel/KnockNotice.d.ts +31 -0
- package/dist/components/admission-panel/answer-all.d.ts +2 -0
- package/dist/components/call-limbo/CallLimbo.d.ts +5 -1
- package/dist/components/chalk/Chalk.d.ts +2 -5
- package/dist/components/chalk/StatusSurface.d.ts +3 -3
- package/dist/components/chalk-ui/ChalkSheet.d.ts +6 -2
- package/dist/components/chalk-ui/InviteLinkButton.d.ts +5 -0
- package/dist/components/chalk-ui/InviteQR.d.ts +4 -0
- package/dist/components/chalk-ui/InviteQrCode.d.ts +3 -0
- package/dist/components/chalk-ui/MenuIcon.d.ts +17 -0
- package/dist/components/chalk-ui/invite-qr-path.d.ts +10 -0
- package/dist/components/chalk-ui/sheet-drag.d.ts +17 -0
- package/dist/components/chalk-ui/useCopyText.d.ts +6 -0
- package/dist/components/chalk-ui/useSheetDrag.d.ts +11 -0
- package/dist/components/composite/ReactionSheet.d.ts +5 -0
- package/dist/components/connection-notice/ConnectionBars.d.ts +4 -0
- package/dist/components/connection-notice/ConnectionNotice.d.ts +12 -0
- package/dist/components/connection-notice/shown-notice.d.ts +12 -0
- package/dist/components/connection-status/ConnectionRing.d.ts +2 -0
- package/dist/components/connection-status/ConnectionStatus.d.ts +24 -0
- package/dist/components/connection-status/LiveConnectionStatus.d.ts +9 -0
- package/dist/components/connection-status/use-connection-phase.d.ts +23 -0
- package/dist/components/control-bar/DockLayout.d.ts +2 -1
- package/dist/components/control-bar/ShareControl.d.ts +3 -1
- package/dist/components/control-bar/ShellIcon.d.ts +18 -6
- package/dist/components/control-bar/control-bar-behavior.d.ts +19 -8
- package/dist/components/control-bar/control-bar-devices.d.ts +8 -0
- package/dist/components/control-bar/useDeviceSheets.d.ts +7 -0
- package/dist/components/device-access/DeviceAccessCard.d.ts +17 -0
- package/dist/components/device-access/DeviceAccessStyles.d.ts +1 -0
- package/dist/components/device-access/DeviceAccessWaiting.d.ts +4 -0
- package/dist/components/device-access/LazyDeviceAccessCard.d.ts +7 -0
- package/dist/components/device-access/browser-marks.d.ts +5 -0
- package/dist/components/device-access/card-copy.d.ts +17 -0
- package/dist/components/device-access/load-card.d.ts +2 -0
- package/dist/components/device-access/model.d.ts +29 -0
- package/dist/components/device-access/ports.d.ts +21 -0
- package/dist/components/device-access/resolve.d.ts +31 -0
- package/dist/components/device-access/store.d.ts +32 -0
- package/dist/components/device-access/useDeviceAccess.d.ts +7 -0
- package/dist/components/device-popover/CameraBackgroundPicker.d.ts +23 -0
- package/dist/components/device-popover/DevicePopover.d.ts +7 -1
- package/dist/components/device-popover/DevicePreview.d.ts +12 -0
- package/dist/components/device-popover/DeviceSheet.d.ts +26 -0
- package/dist/components/index.js +30 -15
- package/dist/components/participant-grid/ParticipantGrid.d.ts +9 -0
- package/dist/components/participant-tile/ParticipantTile.d.ts +12 -1
- package/dist/components/participant-tile/TileConnection.d.ts +9 -0
- package/dist/components/participant-tile/TileShell.d.ts +2 -1
- package/dist/components/participant-tile/useFrozenFrame.d.ts +12 -0
- package/dist/components/participant-tile/useVideoTileVisibility.d.ts +6 -0
- package/dist/components/participants-panel/ParticipantsPanel.d.ts +5 -0
- package/dist/components/participants-panel/participant-options-menu.d.ts +4 -1
- package/dist/components/participants-panel/participant-order.d.ts +13 -0
- package/dist/components/participants-panel/participant-row.d.ts +5 -1
- package/dist/components/participants-panel/participant-search.d.ts +4 -0
- package/dist/components/space-header/CallCharts.d.ts +22 -0
- package/dist/components/space-header/CallDetails.d.ts +5 -13
- package/dist/components/space-header/CallDialog.d.ts +5 -0
- package/dist/components/space-header/CallDialogContent.d.ts +13 -0
- package/dist/components/space-header/CallMenuStyles.d.ts +2 -0
- package/dist/components/space-header/RowIcon.d.ts +12 -0
- package/dist/components/space-header/call-diagnostics.d.ts +2 -1
- package/dist/components/space-header/call-network.d.ts +18 -0
- package/dist/components/space-header/space-header-contract.d.ts +8 -1
- package/dist/components/space-view/SpacePresentation.d.ts +3 -1
- package/dist/components/space-view/SpaceView.d.ts +3 -5
- package/dist/components/space-view/useBoardNotices.d.ts +7 -0
- package/dist/components/space-view/useMicrophoneNotice.d.ts +11 -0
- package/dist/components/toast-stack/ToastStack.d.ts +3 -1
- package/dist/components/toast-stack/call-events.d.ts +4 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +298 -28
- package/dist/internal/call-width.d.ts +9 -0
- package/dist/internal/media-devices.d.ts +11 -0
- package/dist/internal/speaker-test.d.ts +2 -0
- package/dist/internal/useHandOrder.d.ts +2 -0
- package/dist/internal/useHeldWhile.d.ts +2 -0
- package/dist/internal/useInputLevel.d.ts +4 -0
- package/dist/internal/useLongPress.d.ts +15 -0
- package/dist/internal/useSeenConnected.d.ts +9 -0
- package/dist/internal/useSilentMicrophone.d.ts +4 -0
- package/dist/internal/useTrueFor.d.ts +4 -0
- package/dist/participant-options-menu-S3EL6K3M.js +330 -0
- package/dist/pre-join/remembered-devices.d.ts +12 -0
- package/dist/pre-join/usePreJoinDevices.d.ts +47 -0
- package/dist/public-surface.contract.d.ts +1 -1
- package/dist/test-support/index.d.ts +1 -1
- package/dist/test-support/index.js +41 -10
- package/dist/theme.d.ts +32 -32
- package/dist/toast.d.ts +1 -0
- package/dist/toast.js +7 -0
- package/dist/utils/formatClockTime.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +20 -12
- package/package.json +24 -11
- package/dist/components/call-limbo/qr-code.d.ts +0 -4
- package/dist/components/offline-actions/OfflineActions.d.ts +0 -9
- package/dist/components/participants-panel/index.d.ts +0 -2
- package/dist/components/reconnecting-overlay/ReconnectingOverlay.d.ts +0 -12
- package/dist/components/space-header/share-qr.d.ts +0 -2
- package/dist/components/space-view/countdown.d.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
CallLimbo,
|
|
3
4
|
Chalk,
|
|
4
5
|
Logo,
|
|
5
6
|
RecordingHistoryPanel,
|
|
6
7
|
RecordingSpaceView,
|
|
7
|
-
RecordingWhiteboardView
|
|
8
|
-
|
|
8
|
+
RecordingWhiteboardView,
|
|
9
|
+
StatusSurface
|
|
10
|
+
} from "./chunk-4RSCAIFK.js";
|
|
11
|
+
import {
|
|
12
|
+
chalkThemeStyle
|
|
13
|
+
} from "./chunk-XY7WXXME.js";
|
|
9
14
|
import {
|
|
10
15
|
loadRecordingWhiteboardFiles,
|
|
11
16
|
parseRecordingWhiteboardStateV1,
|
|
@@ -15,8 +20,45 @@ import {
|
|
|
15
20
|
} from "./chunk-VHM3SYMY.js";
|
|
16
21
|
import {
|
|
17
22
|
CallDialog,
|
|
18
|
-
CallLimbo,
|
|
19
23
|
CallReady,
|
|
24
|
+
ControlBar,
|
|
25
|
+
NO_DETECTED_DEVICES,
|
|
26
|
+
ShellStyles,
|
|
27
|
+
SpaceHeader,
|
|
28
|
+
ToastStack,
|
|
29
|
+
captureFlip,
|
|
30
|
+
playSpeakerTestTone,
|
|
31
|
+
useMirrorSetting,
|
|
32
|
+
watchMediaDevices
|
|
33
|
+
} from "./chunk-F6QZY5SM.js";
|
|
34
|
+
import "./chunk-CQBYFA2W.js";
|
|
35
|
+
import "./chunk-26PBFST5.js";
|
|
36
|
+
import "./chunk-ALGD3RBI.js";
|
|
37
|
+
import {
|
|
38
|
+
ChalkProvider,
|
|
39
|
+
useCan,
|
|
40
|
+
useChat,
|
|
41
|
+
useConnection,
|
|
42
|
+
useMedia,
|
|
43
|
+
useOffline,
|
|
44
|
+
useParticipants,
|
|
45
|
+
useReactions,
|
|
46
|
+
useRecording,
|
|
47
|
+
useScreenShare,
|
|
48
|
+
useSelf,
|
|
49
|
+
useSpaceClient,
|
|
50
|
+
useWhiteboard
|
|
51
|
+
} from "./chunk-YOWY22N7.js";
|
|
52
|
+
import {
|
|
53
|
+
useInputLevel
|
|
54
|
+
} from "./chunk-SBGC5DKV.js";
|
|
55
|
+
import "./chunk-ES7AECAD.js";
|
|
56
|
+
import "./chunk-SZNV3J4B.js";
|
|
57
|
+
import "./chunk-JDCFKSGV.js";
|
|
58
|
+
import "./chunk-TSBY6C5U.js";
|
|
59
|
+
import "./chunk-E6HPIMFO.js";
|
|
60
|
+
import "./chunk-PMGIER77.js";
|
|
61
|
+
import {
|
|
20
62
|
ChalkAlert,
|
|
21
63
|
ChalkBackdrop,
|
|
22
64
|
ChalkBadge,
|
|
@@ -32,36 +74,261 @@ import {
|
|
|
32
74
|
ChalkMenuLabel,
|
|
33
75
|
ChalkPanel,
|
|
34
76
|
ChalkPopover,
|
|
35
|
-
ChalkProvider,
|
|
36
77
|
ChalkSegmentedControl,
|
|
37
78
|
ChalkSheet,
|
|
38
79
|
ChalkSpinner,
|
|
39
80
|
ChalkTextarea,
|
|
40
|
-
ChalkToast,
|
|
41
81
|
ChalkToggle,
|
|
42
|
-
ChalkTooltip
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
ChalkTooltip
|
|
83
|
+
} from "./chunk-PH3RC6T6.js";
|
|
84
|
+
import {
|
|
85
|
+
ChalkToast
|
|
86
|
+
} from "./chunk-I6FSUWKG.js";
|
|
87
|
+
import "./chunk-ADIDI7AJ.js";
|
|
88
|
+
|
|
89
|
+
// src/pre-join/usePreJoinDevices.ts
|
|
90
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
91
|
+
|
|
92
|
+
// src/pre-join/remembered-devices.ts
|
|
93
|
+
var STORAGE_KEY = "chalk.prejoin-devices";
|
|
94
|
+
function readRememberedDevices() {
|
|
95
|
+
try {
|
|
96
|
+
const raw = globalThis.localStorage.getItem(STORAGE_KEY);
|
|
97
|
+
return raw === null ? null : parseRememberedDevices(JSON.parse(raw));
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function rememberDevices(devices) {
|
|
103
|
+
try {
|
|
104
|
+
globalThis.localStorage.setItem(STORAGE_KEY, JSON.stringify(devices));
|
|
105
|
+
} catch {
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function listedRememberedDevices(devices) {
|
|
109
|
+
const listed = await globalThis.navigator?.mediaDevices?.enumerateDevices().catch(() => []) ?? [];
|
|
110
|
+
const present = (id, kind) => {
|
|
111
|
+
const ofKind = listed.filter((device) => device.kind === kind && device.deviceId !== "");
|
|
112
|
+
return id !== void 0 && (ofKind.length === 0 || ofKind.some((device) => device.deviceId === id));
|
|
113
|
+
};
|
|
114
|
+
const { microphoneDeviceId, cameraDeviceId, speakerDeviceId, ...toggles } = devices;
|
|
115
|
+
return {
|
|
116
|
+
...toggles,
|
|
117
|
+
...present(microphoneDeviceId, "audioinput") ? { microphoneDeviceId } : {},
|
|
118
|
+
...present(cameraDeviceId, "videoinput") ? { cameraDeviceId } : {},
|
|
119
|
+
...present(speakerDeviceId, "audiooutput") ? { speakerDeviceId } : {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function parseRememberedDevices(value) {
|
|
123
|
+
if (typeof value !== "object" || value === null) return null;
|
|
124
|
+
const field = (key) => Reflect.get(value, key);
|
|
125
|
+
const id = (key) => {
|
|
126
|
+
const candidate = field(key);
|
|
127
|
+
return typeof candidate === "string" && candidate !== "" ? candidate : void 0;
|
|
128
|
+
};
|
|
129
|
+
const microphone = field("microphone");
|
|
130
|
+
const camera = field("camera");
|
|
131
|
+
if (typeof microphone !== "boolean" || typeof camera !== "boolean") return null;
|
|
132
|
+
const [microphoneDeviceId, cameraDeviceId, speakerDeviceId] = [id("microphoneDeviceId"), id("cameraDeviceId"), id("speakerDeviceId")];
|
|
133
|
+
return { microphone, camera, ...microphoneDeviceId ? { microphoneDeviceId } : {}, ...cameraDeviceId ? { cameraDeviceId } : {}, ...speakerDeviceId ? { speakerDeviceId } : {} };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/pre-join/usePreJoinDevices.ts
|
|
137
|
+
var NOTHING_CAPTURED = { microphone: null, camera: null, missing: /* @__PURE__ */ new Set(), denied: false };
|
|
138
|
+
function usePreJoinDevices() {
|
|
139
|
+
const [choice, setChoice] = useState(() => readRememberedDevices() ?? { microphone: true, camera: true });
|
|
140
|
+
const [access, setAccess] = useState("checking");
|
|
141
|
+
const [devices, setDevices] = useState(null);
|
|
142
|
+
const [capture, setCapture] = useState(NOTHING_CAPTURED);
|
|
143
|
+
const [generation, setGeneration] = useState(0);
|
|
144
|
+
const [speakerTesting, setSpeakerTesting] = useState(false);
|
|
145
|
+
const [mirrored] = useMirrorSetting();
|
|
146
|
+
const refreshDevices = useRef(() => void 0);
|
|
147
|
+
const stream = useRef(null);
|
|
148
|
+
const latestChoice = useRef(choice);
|
|
149
|
+
const update = (change) => {
|
|
150
|
+
const next = { ...latestChoice.current, ...change };
|
|
151
|
+
latestChoice.current = next;
|
|
152
|
+
setChoice(next);
|
|
153
|
+
};
|
|
154
|
+
const microphones = devices?.audioinput ?? NO_DETECTED_DEVICES.audioinput;
|
|
155
|
+
const cameras = devices?.videoinput ?? NO_DETECTED_DEVICES.videoinput;
|
|
156
|
+
const speakers = devices?.audiooutput ?? NO_DETECTED_DEVICES.audiooutput;
|
|
157
|
+
const chosenMicrophone = knownDevice(choice.microphoneDeviceId, microphones);
|
|
158
|
+
const chosenCamera = knownDevice(choice.cameraDeviceId, cameras);
|
|
159
|
+
const chosenSpeaker = knownDevice(choice.speakerDeviceId, speakers);
|
|
160
|
+
const capturing = access === "granted" || access === "requesting";
|
|
161
|
+
const devicesKnown = devices !== null;
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!navigator.mediaDevices) {
|
|
164
|
+
setDevices(NO_DETECTED_DEVICES);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const watch = watchMediaDevices(setDevices);
|
|
168
|
+
refreshDevices.current = watch.refresh;
|
|
169
|
+
return watch.stop;
|
|
170
|
+
}, []);
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
let cancelled = false;
|
|
173
|
+
const statuses = [];
|
|
174
|
+
const settle = () => {
|
|
175
|
+
if (cancelled) return;
|
|
176
|
+
const states = statuses.map((status) => status.state);
|
|
177
|
+
const next = states.includes("denied") ? "blocked" : states.every((state) => state === "granted") ? "granted" : "ask";
|
|
178
|
+
setAccess((current) => current === "requesting" ? current : next);
|
|
179
|
+
};
|
|
180
|
+
void (async () => {
|
|
181
|
+
try {
|
|
182
|
+
for (const name of ["camera", "microphone"]) statuses.push(await navigator.permissions.query({ name }));
|
|
183
|
+
} catch {
|
|
184
|
+
const known = await navigator.mediaDevices?.enumerateDevices().catch(() => []) ?? [];
|
|
185
|
+
if (!cancelled) setAccess(known.some((device) => device.label !== "") ? "granted" : "ask");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
for (const status of statuses) status.addEventListener("change", settle);
|
|
189
|
+
settle();
|
|
190
|
+
})();
|
|
191
|
+
return () => {
|
|
192
|
+
cancelled = true;
|
|
193
|
+
for (const status of statuses) status.removeEventListener("change", settle);
|
|
194
|
+
};
|
|
195
|
+
}, []);
|
|
196
|
+
const wantMicrophone = capturing && choice.microphone;
|
|
197
|
+
const wantCamera = capturing && choice.camera;
|
|
198
|
+
const hasMicrophone = microphones.length > 0;
|
|
199
|
+
const hasCamera = cameras.length > 0;
|
|
200
|
+
const retryMicrophone = capture.missing.has("microphone") ? microphones.map((device) => device.deviceId).join() : "";
|
|
201
|
+
const retryCamera = capture.missing.has("camera") ? cameras.map((device) => device.deviceId).join() : "";
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (!devicesKnown) return;
|
|
204
|
+
if (!wantMicrophone && !wantCamera) {
|
|
205
|
+
adopt(stream, null);
|
|
206
|
+
setCapture(NOTHING_CAPTURED);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!wantMicrophone) stream.current?.getAudioTracks().forEach((track) => track.stop());
|
|
210
|
+
if (!wantCamera) stream.current?.getVideoTracks().forEach((track) => track.stop());
|
|
211
|
+
let cancelled = false;
|
|
212
|
+
let settled = false;
|
|
213
|
+
const held = [];
|
|
214
|
+
void openPreview(wantMicrophone ? { deviceId: chosenMicrophone } : false, wantCamera ? { deviceId: chosenCamera } : false, held).then((opened) => {
|
|
215
|
+
if (cancelled) {
|
|
216
|
+
opened.stream?.getTracks().forEach((track) => track.stop());
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
settled = true;
|
|
220
|
+
adopt(stream, opened.stream);
|
|
221
|
+
const tracks = { microphone: opened.stream?.getAudioTracks()[0] ?? null, camera: opened.stream?.getVideoTracks()[0] ?? null };
|
|
222
|
+
for (const track of [tracks.microphone, tracks.camera]) track?.addEventListener("ended", () => setGeneration((count) => count + 1), { once: true });
|
|
223
|
+
setCapture({ ...tracks, missing: opened.missing, denied: opened.denied });
|
|
224
|
+
setAccess(opened.denied ? "blocked" : "granted");
|
|
225
|
+
refreshDevices.current();
|
|
226
|
+
});
|
|
227
|
+
return () => {
|
|
228
|
+
cancelled = true;
|
|
229
|
+
if (!settled) held.forEach((captured) => captured.getTracks().forEach((track) => track.stop()));
|
|
230
|
+
};
|
|
231
|
+
}, [devicesKnown, wantMicrophone, wantCamera, chosenMicrophone, chosenCamera, hasMicrophone, hasCamera, retryMicrophone, retryCamera, generation]);
|
|
232
|
+
useEffect(() => () => adopt(stream, null), []);
|
|
233
|
+
const granted = access === "granted";
|
|
234
|
+
const microphoneMissing = granted && (capture.missing.has("microphone") || devicesKnown && !hasMicrophone);
|
|
235
|
+
const cameraMissing = granted && (capture.missing.has("camera") || devicesKnown && !hasCamera);
|
|
236
|
+
const microphoneOn = granted && choice.microphone && !microphoneMissing;
|
|
237
|
+
const cameraOn = granted && choice.camera && !cameraMissing;
|
|
238
|
+
const microphoneId = chosenMicrophone ?? knownDevice(capture.microphone?.getSettings().deviceId, microphones) ?? microphones[0]?.deviceId;
|
|
239
|
+
const cameraId = chosenCamera ?? knownDevice(capture.camera?.getSettings().deviceId, cameras) ?? cameras[0]?.deviceId;
|
|
240
|
+
const canChooseSpeaker = typeof HTMLMediaElement !== "undefined" && "setSinkId" in HTMLMediaElement.prototype;
|
|
241
|
+
const speakerId = chosenSpeaker ?? speakers[0]?.deviceId;
|
|
242
|
+
const microphoneLevel = useInputLevel(microphoneOn ? capture.microphone : null);
|
|
243
|
+
const testSpeaker = useCallback(async () => {
|
|
244
|
+
setSpeakerTesting(true);
|
|
245
|
+
try {
|
|
246
|
+
await playSpeakerTestTone(chosenSpeaker);
|
|
247
|
+
} catch {
|
|
248
|
+
} finally {
|
|
249
|
+
setSpeakerTesting(false);
|
|
250
|
+
}
|
|
251
|
+
}, [chosenSpeaker]);
|
|
252
|
+
const joinOptions = useMemo(
|
|
253
|
+
() => ({
|
|
254
|
+
microphone: microphoneOn,
|
|
255
|
+
camera: cameraOn,
|
|
256
|
+
...granted && microphoneId ? { microphoneDeviceId: microphoneId } : {},
|
|
257
|
+
...granted && cameraId ? { cameraDeviceId: cameraId } : {},
|
|
258
|
+
...granted && canChooseSpeaker && chosenSpeaker ? { speakerDeviceId: chosenSpeaker } : {}
|
|
259
|
+
}),
|
|
260
|
+
[granted, microphoneOn, cameraOn, microphoneId, cameraId, canChooseSpeaker, chosenSpeaker]
|
|
261
|
+
);
|
|
262
|
+
return {
|
|
263
|
+
access,
|
|
264
|
+
requestAccess: () => {
|
|
265
|
+
setAccess("requesting");
|
|
266
|
+
update({ microphone: true, camera: true });
|
|
267
|
+
},
|
|
268
|
+
microphones,
|
|
269
|
+
cameras,
|
|
270
|
+
speakers,
|
|
271
|
+
microphoneId,
|
|
272
|
+
cameraId,
|
|
273
|
+
speakerId,
|
|
274
|
+
microphoneOn,
|
|
275
|
+
cameraOn,
|
|
276
|
+
microphoneMissing,
|
|
277
|
+
cameraMissing,
|
|
278
|
+
setMicrophoneOn: (on) => update({ microphone: on }),
|
|
279
|
+
setCameraOn: (on) => update({ camera: on }),
|
|
280
|
+
selectMicrophone: (deviceId) => update({ microphoneDeviceId: deviceId }),
|
|
281
|
+
selectCamera: (deviceId) => update({ cameraDeviceId: deviceId }),
|
|
282
|
+
selectSpeaker: (deviceId) => update({ speakerDeviceId: deviceId }),
|
|
283
|
+
cameraTrack: cameraOn ? capture.camera : null,
|
|
284
|
+
microphoneLevel,
|
|
285
|
+
mirrored,
|
|
286
|
+
canChooseSpeaker,
|
|
287
|
+
speakerTesting,
|
|
288
|
+
testSpeaker,
|
|
289
|
+
joinOptions,
|
|
290
|
+
commit: () => {
|
|
291
|
+
if (granted) rememberDevices(latestChoice.current);
|
|
292
|
+
return joinOptions;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function knownDevice(deviceId, listed) {
|
|
297
|
+
return deviceId !== void 0 && listed.some((device) => device.deviceId === deviceId) ? deviceId : void 0;
|
|
298
|
+
}
|
|
299
|
+
function adopt(current, next) {
|
|
300
|
+
current.current?.getTracks().forEach((track) => track.stop());
|
|
301
|
+
current.current = next;
|
|
302
|
+
}
|
|
303
|
+
async function openPreview(microphone, camera, held) {
|
|
304
|
+
const together = await attempt(microphone, camera, held);
|
|
305
|
+
if (together.stream) return { stream: together.stream, missing: /* @__PURE__ */ new Set(), denied: false };
|
|
306
|
+
const separate = microphone && camera ? [await attempt(microphone, false, held), await attempt(false, camera, held)] : [together];
|
|
307
|
+
const sources = microphone && camera ? ["microphone", "camera"] : [microphone ? "microphone" : "camera"];
|
|
308
|
+
const tracks = separate.flatMap((result) => result.stream?.getTracks() ?? []);
|
|
309
|
+
const missing = new Set(sources.filter((_, index) => separate[index]?.stream === void 0));
|
|
310
|
+
return { stream: tracks.length > 0 ? new MediaStream(tracks) : null, missing, denied: tracks.length === 0 && separate.some((result) => result.failure === "denied") };
|
|
311
|
+
}
|
|
312
|
+
async function attempt(microphone, camera, held) {
|
|
313
|
+
if (!microphone && !camera) return { failure: "missing" };
|
|
314
|
+
try {
|
|
315
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: constraint(microphone), video: constraint(camera) });
|
|
316
|
+
held.push(stream);
|
|
317
|
+
return { stream };
|
|
318
|
+
} catch (cause) {
|
|
319
|
+
return { failure: classify(cause) };
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function constraint(request) {
|
|
323
|
+
if (!request) return false;
|
|
324
|
+
return request.deviceId === void 0 ? true : { deviceId: { exact: request.deviceId } };
|
|
325
|
+
}
|
|
326
|
+
function classify(cause) {
|
|
327
|
+
const name = cause instanceof DOMException ? cause.name : "";
|
|
328
|
+
if (name === "NotAllowedError" || name === "SecurityError") return "denied";
|
|
329
|
+
if (name === "NotFoundError" || name === "OverconstrainedError") return "missing";
|
|
330
|
+
return "failed";
|
|
331
|
+
}
|
|
65
332
|
|
|
66
333
|
// src/index.ts
|
|
67
334
|
import { CHALK_REACTIONS } from "@q9labsai/chalk-client";
|
|
@@ -120,8 +387,10 @@ export {
|
|
|
120
387
|
StatusSurface,
|
|
121
388
|
ToastStack,
|
|
122
389
|
captureFlip,
|
|
390
|
+
listedRememberedDevices,
|
|
123
391
|
loadRecordingWhiteboardFiles,
|
|
124
392
|
parseRecordingWhiteboardStateV1,
|
|
393
|
+
readRememberedDevices,
|
|
125
394
|
recordingWhiteboardBinaryFile,
|
|
126
395
|
recordingWhiteboardFileAssetId,
|
|
127
396
|
recordingWhiteboardFileIds,
|
|
@@ -131,6 +400,7 @@ export {
|
|
|
131
400
|
useMedia,
|
|
132
401
|
useOffline,
|
|
133
402
|
useParticipants,
|
|
403
|
+
usePreJoinDevices,
|
|
134
404
|
useReactions,
|
|
135
405
|
useRecording,
|
|
136
406
|
useScreenShare,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
export declare const PHONE_CALL_WIDTH = 640;
|
|
3
|
+
export declare const NarrowCallProvider: import("react").Provider<boolean | null>;
|
|
4
|
+
/** Whether a call frame's content box is phone width, as the `chalk-call` container rules measure it; null until measured. */
|
|
5
|
+
export declare function useNarrowCallFrame(frame: RefObject<HTMLElement | null>): boolean | null;
|
|
6
|
+
/** Inside a call, whether the call is phone width; null outside a call. */
|
|
7
|
+
export declare function useNarrowCall(): boolean | null;
|
|
8
|
+
/** Whether the call is phone width, by its own frame or by the window; the phone rules in ShellStyles follow the same two. */
|
|
9
|
+
export declare function usePhoneCall(): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type DetectedMediaDevices = {
|
|
2
|
+
readonly audioinput: MediaDeviceInfo[];
|
|
3
|
+
readonly audiooutput: MediaDeviceInfo[];
|
|
4
|
+
readonly videoinput: MediaDeviceInfo[];
|
|
5
|
+
};
|
|
6
|
+
export declare const NO_DETECTED_DEVICES: DetectedMediaDevices;
|
|
7
|
+
/** Reports the browser's device list now and after each `devicechange`; `refresh` reads it again, for example once permission adds labels. */
|
|
8
|
+
export declare function watchMediaDevices(onChange: (devices: DetectedMediaDevices) => void): {
|
|
9
|
+
readonly refresh: () => void;
|
|
10
|
+
readonly stop: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A sample is null when the browser isn't providing live, readable input. */
|
|
2
|
+
export declare function observeInputLevel(track: MediaStreamTrack, sample: (rms: number | null) => void): (() => void) | undefined;
|
|
3
|
+
/** The loudness of a microphone track from 0 to 100, sampled every 100 ms. */
|
|
4
|
+
export declare function useInputLevel(track?: MediaStreamTrack | null): number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type MouseEvent, type PointerEvent } from "react";
|
|
2
|
+
export declare const LONG_PRESS_MS = 400;
|
|
3
|
+
/**
|
|
4
|
+
* Handlers for a button that does one thing on tap and another on a 400 ms hold.
|
|
5
|
+
* After a hold fires, the click that follows the release is swallowed, so the tap action does not also run.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useLongPress(onLongPress: (() => void) | undefined): {
|
|
8
|
+
onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
9
|
+
onPointerMove: (event: PointerEvent<HTMLElement>) => void;
|
|
10
|
+
onPointerUp: () => void;
|
|
11
|
+
onPointerCancel: () => void;
|
|
12
|
+
onPointerLeave: () => void;
|
|
13
|
+
onClickCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
14
|
+
onContextMenu: (event: MouseEvent<HTMLElement>) => void;
|
|
15
|
+
} | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Seat = {
|
|
2
|
+
readonly participantId: string;
|
|
3
|
+
readonly presence: {
|
|
4
|
+
readonly state: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/** The people who have shown as connected at some point in this call, so a seat that never joined is not called reconnecting. */
|
|
8
|
+
export declare function useSeenConnected(roster: readonly Seat[]): ReadonlySet<string>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** True once `value` has stayed true for `milliseconds`; false again the moment it turns false. */
|
|
2
|
+
export declare function useTrueFor(value: boolean, milliseconds: number): boolean;
|
|
3
|
+
/** Whole seconds since `since`, counted by the page's own clock, or 0 while `since` is null. */
|
|
4
|
+
export declare function useElapsedSeconds(since: number | null): number;
|