@theoremjs/react 0.3.5-next.1029.g543179b → 0.3.5-next.1031.g1faef7b
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 +84 -4
- package/client/decision-images.d.ts +1 -1
- package/client/decision-images.js +1 -1
- package/client/ink-waveform.d.ts +1 -1
- package/client/ink-waveform.js +1 -1
- package/client/live/live-video-view.d.ts +38 -0
- package/client/live/live-video-view.js +19 -0
- package/client/live/live-video.d.ts +63 -3
- package/client/live/live-video.js +95 -18
- package/components/live/use-live-call.d.ts +14 -2
- package/components/live/use-live-call.js +32 -1
- package/components/live/use-live-runner-controls.d.ts +3 -1
- package/components/live/use-live-runner-controls.js +3 -2
- package/components/live/use-live-session-client.js +18 -0
- package/live.d.ts +7 -3
- package/live.js +3 -1
- package/package.json +3 -3
- package/ui/ChatComposerBar.d.ts +6 -1
- package/ui/ChatComposerBar.js +19 -4
- package/ui/ConsoleFrame.d.ts +1 -1
- package/ui/LiveCallTile.d.ts +14 -0
- package/ui/LiveCallTile.js +17 -9
- package/ui/LiveCaptionsPanel.d.ts +4 -0
- package/ui/LiveCaptionsPanel.js +5 -3
- package/ui/LiveMicToggle.d.ts +6 -0
- package/ui/LiveMicToggle.js +10 -0
- package/ui/LiveRunner.d.ts +21 -0
- package/ui/LiveRunner.js +34 -22
- package/ui/LiveVideoPreview.d.ts +16 -6
- package/ui/LiveVideoPreview.js +35 -14
- package/ui/TheoremChat.d.ts +5 -1
- package/ui/TheoremChat.js +9 -8
- package/ui/arrive.d.ts +1 -1
- package/ui/labels.d.ts +4 -0
- package/ui/labels.js +4 -0
- package/ui/live-slots.d.ts +43 -0
- package/ui/live-slots.js +34 -0
package/live.d.ts
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
export type { LiveCallOptions, LiveConnection, PageTool, PageToolAnswer, PageTools, } from '@theoremjs/web/client';
|
|
6
|
+
export type { LiveAudioOptions, LiveCallOptions, LiveClientTuning, LiveConnection, PageTool, PageToolAnswer, PageTools, } from '@theoremjs/web/client';
|
|
7
|
+
export type { LiveFacingMode, LiveVideoFrame, LiveVideoOptions, } from './client/live/live-video.js';
|
|
8
|
+
export { type LiveVideoFit, type LiveVideoOverlay, type LiveVideoView, liveFramePointInPreview, } from './client/live/live-video-view.js';
|
|
7
9
|
export { type LiveCall, type LiveCallInput, useLiveCall, } from './components/live/use-live-call.js';
|
|
8
|
-
export { LiveCallTile, type LiveCallTileProps } from './ui/LiveCallTile.js';
|
|
9
|
-
export type { LiveRunnerProps } from './ui/LiveRunner.js';
|
|
10
|
+
export { LiveCallTile, type LiveCallTileProps, type LiveCallTileSlots, } from './ui/LiveCallTile.js';
|
|
11
|
+
export type { LiveRunnerProps, LiveRunnerSlots } from './ui/LiveRunner.js';
|
|
10
12
|
export { LiveRunner } from './ui/LiveRunner.js';
|
|
13
|
+
export { LiveVideoPreview, type LiveVideoPreviewProps } from './ui/LiveVideoPreview.js';
|
|
14
|
+
export type { LiveControl, LiveControlId, LiveControlsSlot, LiveSlot, LiveVideoPreviewOptions, } from './ui/live-slots.js';
|
package/live.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import '@astryxdesign/core/reset.css';
|
|
8
8
|
import '@astryxdesign/core/astryx.css';
|
|
9
9
|
import './ui/built/theme.css';
|
|
10
|
+
export { liveFramePointInPreview, } from "./client/live/live-video-view.js";
|
|
10
11
|
export { useLiveCall, } from "./components/live/use-live-call.js";
|
|
11
|
-
export { LiveCallTile } from "./ui/LiveCallTile.js";
|
|
12
|
+
export { LiveCallTile, } from "./ui/LiveCallTile.js";
|
|
12
13
|
export { LiveRunner } from "./ui/LiveRunner.js";
|
|
14
|
+
export { LiveVideoPreview } from "./ui/LiveVideoPreview.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/react",
|
|
3
|
-
"version": "0.3.5-next.
|
|
3
|
+
"version": "0.3.5-next.1031.g1faef7b",
|
|
4
4
|
"description": "React bindings for Theorem: headless hooks + transport, an Astryx chat UI, and a Web-standard server handler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@stylexjs/stylex": "0.19.0",
|
|
61
61
|
"react": "^19.0.0",
|
|
62
62
|
"react-dom": "^19.0.0",
|
|
63
|
-
"@theoremjs/agents": "^0.3.5-next.
|
|
64
|
-
"@theoremjs/web": "^0.3.5-next.
|
|
63
|
+
"@theoremjs/agents": "^0.3.5-next.1031.g1faef7b",
|
|
64
|
+
"@theoremjs/web": "^0.3.5-next.1031.g1faef7b"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|
package/ui/ChatComposerBar.d.ts
CHANGED
|
@@ -88,9 +88,14 @@ export type ChatComposerBarProps = {
|
|
|
88
88
|
onPendingQueue: (id: string) => void;
|
|
89
89
|
onPendingRestore: (id: string) => void;
|
|
90
90
|
onPendingSendNow: (id: string) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Stands in for the send button while the composer holds nothing to send, such as a button that
|
|
93
|
+
* starts a call. Never replaces stop or the send menu. Omit to keep the send button.
|
|
94
|
+
*/
|
|
95
|
+
emptyAction?: ReactNode;
|
|
91
96
|
};
|
|
92
97
|
/** A Live call's text line: it is sent as typed, so there is nothing to attach, queue, or stop. */
|
|
93
|
-
export type LiveComposerBarProps = Omit<Pick<ChatComposerBarProps, 'draftText' | 'placeholder' | 'inputRef' | 'inputComponent' | 'triggers' | 'draftParts' | 'onDraftPartsChange' | 'refText' | 'renderRef' | 'onDraftTextChange' | 'onSubmit'>, 'onSubmit'> & {
|
|
98
|
+
export type LiveComposerBarProps = Omit<Pick<ChatComposerBarProps, 'draftText' | 'placeholder' | 'inputRef' | 'inputComponent' | 'triggers' | 'draftParts' | 'onDraftPartsChange' | 'refText' | 'renderRef' | 'onDraftTextChange' | 'onSubmit' | 'emptyAction'>, 'onSubmit'> & {
|
|
94
99
|
/** The typed line. The button reads the field, so this is the text, not the click. */
|
|
95
100
|
onSubmit: (text: string) => void;
|
|
96
101
|
/** The live profile, when the host has one. The placeholder uses its handle. */
|
package/ui/ChatComposerBar.js
CHANGED
|
@@ -14,7 +14,7 @@ import { VStack } from '@astryxdesign/core/VStack';
|
|
|
14
14
|
import { IconAdjustmentsHorizontal, IconArchive, IconArrowBigRightLines, IconArrowDown, IconArrowUp, IconBrain, IconCornerDownLeft, IconInputAi, IconListNumbers, IconMicrophone, IconPaperclip, IconPencil, IconPlayerRecordFilled, IconSend, IconStack2, IconSteeringWheel, IconX, } from '@tabler/icons-react';
|
|
15
15
|
import { attachmentIssueText, labelText } from '@theoremjs/agents';
|
|
16
16
|
import { composerPendingMoves, composerPendingPreview, effortSelectEnabled, interfaceEffortOptions, interfaceModelOptions, modelSelectEnabled, } from '@theoremjs/agents/interface';
|
|
17
|
-
import { COMPOSER_SHORTCUTS, composerActionState, composerDrawerSummary, composerShortcut, resolveComposerHint, } from '@theoremjs/web/client';
|
|
17
|
+
import { COMPOSER_SHORTCUTS, composerActionState, composerDrawerSummary, composerHasPayload, composerShortcut, composerShowsEmptyAction, resolveComposerHint, } from '@theoremjs/web/client';
|
|
18
18
|
import { useEffect, useMemo, useRef, useState, } from 'react';
|
|
19
19
|
import { stageComposerFiles } from "../client/composer-attachments.js";
|
|
20
20
|
import { useComposerVoice } from "../components/use-composer-voice.js";
|
|
@@ -340,7 +340,12 @@ function LiveComposerBarBody(props) {
|
|
|
340
340
|
return (_jsx(ChatComposer, { style: NO_FOCUS_RING, value: props.draftText, onChange: refs.onChange, onSubmit: props.onSubmit, isDisabled: props.isDisabled, placeholder: props.placeholder ??
|
|
341
341
|
t('@theorem.composer.placeholder', {
|
|
342
342
|
handle: props.handle ?? props.iface?.identity.handle ?? '',
|
|
343
|
-
}), input: refs.provide(_jsx(Input, { ref: rootRef, handleRef: refs.handleRef, ...(props.triggers ? { triggers: props.triggers } : {}) })), sendButton:
|
|
343
|
+
}), input: refs.provide(_jsx(Input, { ref: rootRef, handleRef: refs.handleRef, ...(props.triggers ? { triggers: props.triggers } : {}) })), sendButton: props.emptyAction !== undefined &&
|
|
344
|
+
composerShowsEmptyAction({
|
|
345
|
+
hasPayload: composerHasPayload(props.draftText, [], []),
|
|
346
|
+
primary: 'send',
|
|
347
|
+
opensMenu: false,
|
|
348
|
+
}) ? (props.emptyAction) : (_jsx(ChatSendButton, { isDisabled: props.isDisabled, onSend: submitTyped })) }));
|
|
344
349
|
}
|
|
345
350
|
function ChatComposerBarBody(props) {
|
|
346
351
|
const parts = useComposerParts(props);
|
|
@@ -443,7 +448,12 @@ function RowComposerBar({ props, parts, }) {
|
|
|
443
448
|
// why: Stop lives on the working pill, so the button only sends; while a reply runs or a
|
|
444
449
|
// step waits, a draft opens the send menu instead (Enter still queues).
|
|
445
450
|
const opensMenu = props.phase !== 'idle' && parts.menuActions.length > 0;
|
|
446
|
-
return (_jsx(ChatComposerRow, { isWorking: props.phase === 'streaming', workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs ?? [], pills: props.pills, onStop: props.onStop, hint: parts.hintNode, tray: parts.tray, attach: parts.attach, input: parts.input, editorRef: parts.editorRef, draftText: props.draftText, controls: parts.controls, record: parts.record, action:
|
|
451
|
+
return (_jsx(ChatComposerRow, { isWorking: props.phase === 'streaming', workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs ?? [], pills: props.pills, onStop: props.onStop, hint: parts.hintNode, tray: parts.tray, attach: parts.attach, input: parts.input, editorRef: parts.editorRef, draftText: props.draftText, controls: parts.controls, record: parts.record, action: props.emptyAction !== undefined &&
|
|
452
|
+
composerShowsEmptyAction({
|
|
453
|
+
hasPayload: parts.hasPayload,
|
|
454
|
+
primary: parts.primary,
|
|
455
|
+
opensMenu,
|
|
456
|
+
}) ? (props.emptyAction) : opensMenu ? (_jsx(SendMenu, { actions: parts.menuActions, phase: props.phase, onAction: props.onMenuAction, trigger: "send" })) : (_jsx(ChatSendButton, { isDisabled: parts.primaryDisabled || parts.primary === 'stop', onSend: parts.runPrimary })), status: parts.status }));
|
|
447
457
|
}
|
|
448
458
|
/** Today's layout: Astryx's ChatComposer. */
|
|
449
459
|
function StackedComposerBar({ props, parts, }) {
|
|
@@ -456,5 +466,10 @@ function StackedComposerBar({ props, parts, }) {
|
|
|
456
466
|
// focus-outline token for this subtree. The editor still shows its caret.
|
|
457
467
|
style: NO_FOCUS_RING, value: props.draftText, onChange: parts.onDraftTextChange, onSubmit: parts.runPrimary, onStop: props.onStop, isStopShown: isStopShown, placeholder: parts.placeholder, input: parts.input, drawer: parts.tray && (_jsx(ChatComposerDrawer, { count: parts.tray.count, label: parts.tray.label, children: parts.tray.content })), headerActions: parts.attach, headerContext: parts.hintNode, footerActions: parts.controls,
|
|
458
468
|
// why: Astryx: sendActions render to the left of the send button, at size="md".
|
|
459
|
-
sendActions: _jsxs(_Fragment, { children: [_jsx(SendMenu, { actions: parts.menuActions, phase: props.phase, onAction: props.onMenuAction }), parts.record] }), sendButton:
|
|
469
|
+
sendActions: _jsxs(_Fragment, { children: [_jsx(SendMenu, { actions: parts.menuActions, phase: props.phase, onAction: props.onMenuAction }), parts.record] }), sendButton: props.emptyAction !== undefined &&
|
|
470
|
+
composerShowsEmptyAction({
|
|
471
|
+
hasPayload: parts.hasPayload,
|
|
472
|
+
primary: parts.primary,
|
|
473
|
+
opensMenu: false,
|
|
474
|
+
}) ? (props.emptyAction) : (_jsx(ChatSendButton, { isStopShown: isStopShown, isDisabled: parts.primaryDisabled, onSend: parts.runPrimary, onStop: props.onStop })), status: parts.status }));
|
|
460
475
|
}
|
package/ui/ConsoleFrame.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare function ResponseColumn({ label, fill, children, }: {
|
|
|
66
66
|
label: string;
|
|
67
67
|
fill?: boolean;
|
|
68
68
|
children: ReactNode;
|
|
69
|
-
}): string | number | bigint | boolean |
|
|
69
|
+
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
70
70
|
export type ConsoleView = 'fields' | 'json';
|
|
71
71
|
export type RequestCardProps = {
|
|
72
72
|
title: string;
|
package/ui/LiveCallTile.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { DefinedTheme } from '@astryxdesign/core/theme';
|
|
2
2
|
import type { LiveCall } from '../components/live/use-live-call.js';
|
|
3
3
|
import { type TheoremLabels } from './labels.js';
|
|
4
|
+
import { type LiveControlsSlot, type LiveSlot, type LiveVideoPreviewOptions } from './live-slots.js';
|
|
5
|
+
/** The parts of `LiveCallTile` a host can change; see {@link LiveSlot}. */
|
|
6
|
+
export type LiveCallTileSlots = {
|
|
7
|
+
/** The camera preview, or the waveform while the camera is off. */
|
|
8
|
+
media?: LiveSlot;
|
|
9
|
+
/** The call time, or its state. */
|
|
10
|
+
time?: LiveSlot;
|
|
11
|
+
controls?: LiveControlsSlot;
|
|
12
|
+
/** The tool gate dialog. */
|
|
13
|
+
gate?: LiveSlot;
|
|
14
|
+
};
|
|
4
15
|
export type LiveCallTileProps = {
|
|
5
16
|
/** The call to draw, from `useLiveCall`: the same call `LiveRunner` draws. */
|
|
6
17
|
call: LiveCall;
|
|
@@ -15,6 +26,9 @@ export type LiveCallTileProps = {
|
|
|
15
26
|
mode?: 'system' | 'light' | 'dark';
|
|
16
27
|
/** Replacement lines by locale, as on `LiveRunner`. */
|
|
17
28
|
labels?: TheoremLabels;
|
|
29
|
+
slots?: LiveCallTileSlots;
|
|
30
|
+
/** How the camera preview is drawn, and what is drawn over it. */
|
|
31
|
+
video?: LiveVideoPreviewOptions;
|
|
18
32
|
};
|
|
19
33
|
/**
|
|
20
34
|
* A small view of a running call: the camera preview, or the ink waveform
|
package/ui/LiveCallTile.js
CHANGED
|
@@ -6,15 +6,16 @@ import { Icon } from '@astryxdesign/core/Icon';
|
|
|
6
6
|
import { IconButton } from '@astryxdesign/core/IconButton';
|
|
7
7
|
import { StackItem } from '@astryxdesign/core/Stack';
|
|
8
8
|
import { Text } from '@astryxdesign/core/Text';
|
|
9
|
-
import { ToggleButton } from '@astryxdesign/core/ToggleButton';
|
|
10
9
|
import { VStack } from '@astryxdesign/core/VStack';
|
|
11
|
-
import { IconArrowsDiagonal,
|
|
10
|
+
import { IconArrowsDiagonal, IconPhoneOff } from '@tabler/icons-react';
|
|
12
11
|
import { InkWaveform } from "../components/InkWaveform.js";
|
|
13
12
|
import { useSecondTicker } from "../hooks/use-second-ticker.js";
|
|
13
|
+
import { LiveMicToggle } from "./LiveMicToggle.js";
|
|
14
14
|
import { LiveToolGateDialog } from "./LiveToolGateDialog.js";
|
|
15
15
|
import { LiveVideoPreview } from "./LiveVideoPreview.js";
|
|
16
16
|
import { liveDuration, liveStateLabel } from "./labels.js";
|
|
17
17
|
import { TheoremLabelsProvider, useLabels } from "./labels-provider.js";
|
|
18
|
+
import { liveControlIds, renderLiveControls, renderLiveSlot, } from "./live-slots.js";
|
|
18
19
|
import { TheoremThemeProvider } from "./theme.js";
|
|
19
20
|
/**
|
|
20
21
|
* A small view of a running call: the camera preview, or the ink waveform
|
|
@@ -30,16 +31,16 @@ export function LiveCallTile({ theme, mode, labels, ...props }) {
|
|
|
30
31
|
const TILE_BORDERLESS = { borderWidth: 0 };
|
|
31
32
|
/** The bars in the icon colour, as on `LiveRunner`'s stage. */
|
|
32
33
|
const WAVE_COLOR = { color: 'var(--color-icon-primary)' };
|
|
33
|
-
function LiveCallTileBody({ call, onExpand, }) {
|
|
34
|
+
function LiveCallTileBody({ call, onExpand, slots = {}, video, }) {
|
|
34
35
|
const t = useLabels();
|
|
35
|
-
return (_jsxs(_Fragment, { children: [_jsx(ClickableCard, { label: t('@theorem.live.expand'), onClick: onExpand, padding: 0, elevation: "high", width: "100%", style: TILE_BORDERLESS, children: _jsxs(VStack, { children: [_jsx(TileMedia, { call: call }), _jsxs(HStack, { gap: 1, vAlign: "center", padding: 2, children: [_jsx(StackItem, { size: "fill", children: _jsx(TileTime, { call: call }) }), _jsx(TileControls, { call: call, onExpand: onExpand })] })] }) }), _jsx(LiveToolGateDialog, { call: call })] }));
|
|
36
|
+
return (_jsxs(_Fragment, { children: [_jsx(ClickableCard, { label: t('@theorem.live.expand'), onClick: onExpand, padding: 0, elevation: "high", width: "100%", style: TILE_BORDERLESS, children: _jsxs(VStack, { children: [renderLiveSlot(slots.media, call, _jsx(TileMedia, { call: call, video: video })), _jsxs(HStack, { gap: 1, vAlign: "center", padding: 2, children: [_jsx(StackItem, { size: "fill", children: renderLiveSlot(slots.time, call, _jsx(TileTime, { call: call })) }), _jsx(TileControls, { call: call, onExpand: onExpand, slot: slots.controls })] })] }) }), renderLiveSlot(slots.gate, call, _jsx(LiveToolGateDialog, { call: call }))] }));
|
|
36
37
|
}
|
|
37
38
|
/** The camera preview while the camera is on; otherwise the ink waveform. */
|
|
38
|
-
function TileMedia({ call }) {
|
|
39
|
+
function TileMedia({ call, video, }) {
|
|
39
40
|
if (call.isVideoOn && call.videoPreview) {
|
|
40
|
-
return _jsx(LiveVideoPreview, { video: call.videoPreview, facingMode: call.videoFacingMode });
|
|
41
|
+
return (_jsx(LiveVideoPreview, { ...video, video: call.videoPreview, facingMode: call.videoFacingMode }));
|
|
41
42
|
}
|
|
42
|
-
return (_jsx(AspectRatio, { ratio: 4 / 3, children: _jsx(VStack, { height: "100%", vAlign: "center", paddingBlock: 4, style: WAVE_COLOR, "aria-hidden": "true", children: _jsx(InkWaveform, { status: call.status, levelsRef: call.levelsRef, toolActive: call.toolActive, variant: "pill" }) }) }));
|
|
43
|
+
return (_jsx(AspectRatio, { ratio: video?.aspectRatio ?? 4 / 3, children: _jsx(VStack, { height: "100%", vAlign: "center", paddingBlock: 4, style: WAVE_COLOR, "aria-hidden": "true", children: _jsx(InkWaveform, { status: call.status, levelsRef: call.levelsRef, toolActive: call.toolActive, variant: "pill" }) }) }));
|
|
43
44
|
}
|
|
44
45
|
/** How long the call has run, or its state: before it connects, after it ends, and while a tool runs. */
|
|
45
46
|
function TileTime({ call }) {
|
|
@@ -50,7 +51,14 @@ function TileTime({ call }) {
|
|
|
50
51
|
? liveStateLabel(t, call.liveState, call.activeTool)
|
|
51
52
|
: liveDuration(t, now - since) }));
|
|
52
53
|
}
|
|
53
|
-
function TileControls({ call, onExpand }) {
|
|
54
|
+
function TileControls({ call, onExpand, slot, }) {
|
|
54
55
|
const t = useLabels();
|
|
55
|
-
|
|
56
|
+
const parts = {
|
|
57
|
+
mic: () => _jsx(LiveMicToggle, { call: call, size: "sm" }, "mic"),
|
|
58
|
+
call: () => (_jsx(IconButton, { label: t('@theorem.live.end_call'), tooltip: t('@theorem.live.end_call'), variant: "destructive", size: "sm", isDisabled: !call.sessionActive, icon: _jsx(Icon, { icon: IconPhoneOff }), onClick: call.handleEnd }, "call")),
|
|
59
|
+
expand: () => (_jsx(IconButton, { label: t('@theorem.live.expand'), tooltip: t('@theorem.live.expand'), variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconArrowsDiagonal }), onClick: onExpand }, "expand")),
|
|
60
|
+
};
|
|
61
|
+
const ids = liveControlIds({ voiceAvailable: call.voiceAvailable, videoAvailable: false }, { minimize: false, captions: false, expand: true });
|
|
62
|
+
const controls = ids.map((id) => ({ id, node: parts[id]?.() ?? null }));
|
|
63
|
+
return _jsx(_Fragment, { children: renderLiveControls(slot, call, controls) });
|
|
56
64
|
}
|
|
@@ -14,6 +14,10 @@ export type LiveCaptionsPanelProps = {
|
|
|
14
14
|
showComposer?: boolean;
|
|
15
15
|
/** Drawn above the transcript. The live runner puts the camera here. */
|
|
16
16
|
leading?: ReactNode;
|
|
17
|
+
/** Drawn in place of the text composer; `null` draws none. Left out, Theorem's composer. */
|
|
18
|
+
composer?: ReactNode;
|
|
19
|
+
/** Drawn while there are no captions; `null` draws none. Left out, Theorem's empty state. */
|
|
20
|
+
empty?: ReactNode;
|
|
17
21
|
};
|
|
18
22
|
/**
|
|
19
23
|
* The live call's captions: the chat transcript, an empty state, and the text
|
package/ui/LiveCaptionsPanel.js
CHANGED
|
@@ -16,12 +16,14 @@ import { PanelScroll } from "./SidePanel.js";
|
|
|
16
16
|
export function LiveCaptionsPanel(props) {
|
|
17
17
|
return (_jsx(TheoremLabelsProvider, { children: _jsx(LiveCaptionsBody, { ...props }) }));
|
|
18
18
|
}
|
|
19
|
-
function LiveCaptionsBody({ handle, captions, pastCalls, draftText, onDraftTextChange, onSubmit, isDisabled, showComposer = true, leading, }) {
|
|
19
|
+
function LiveCaptionsBody({ handle, captions, pastCalls, draftText, onDraftTextChange, onSubmit, isDisabled, showComposer = true, leading, composer: hostComposer, empty: hostEmpty, }) {
|
|
20
20
|
const t = useLabels();
|
|
21
21
|
const agentName = t('@theorem.agent.handle', { handle });
|
|
22
22
|
const { blocks, callStarts } = liveCaptionTranscript(pastCalls, captions);
|
|
23
23
|
const newSession = t('@theorem.live.new_session');
|
|
24
24
|
const dividers = Object.fromEntries(callStarts.map((id) => [id, newSession]));
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const standardComposer = showComposer ? (_jsx(ChatComposerBar, { handle: handle, draftText: draftText, onDraftTextChange: onDraftTextChange, onSubmit: onSubmit, isDisabled: isDisabled })) : null;
|
|
26
|
+
const composer = hostComposer === undefined ? standardComposer : hostComposer;
|
|
27
|
+
const empty = hostEmpty === undefined ? (_jsx(VStack, { height: "100%", vAlign: "center", padding: 4, children: _jsx(EmptyState, { icon: _jsx(Icon, { icon: IconSubtitles, size: "lg", color: "secondary" }), title: t('@theorem.panel.captions.empty.title'), description: t('@theorem.panel.captions.empty.description'), isCompact: true }) })) : (hostEmpty);
|
|
28
|
+
return (_jsxs(VStack, { height: "100%", children: [leading, _jsx(StackItem, { size: "fill", children: blocks.length > 0 ? (_jsx(PanelScroll, { label: t('@theorem.panel.captions.name'), children: _jsx(ChatTranscript, { blocks: blocks, dividers: dividers, handle: agentName, streaming: liveCaptionStreaming(captions) }) })) : (empty) }), composer] }));
|
|
27
29
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LiveCall } from '../components/live/use-live-call.js';
|
|
2
|
+
/** The microphone toggle every live view draws. A slash on the icon means a click mutes. */
|
|
3
|
+
export declare function LiveMicToggle({ call, size }: {
|
|
4
|
+
call: LiveCall;
|
|
5
|
+
size?: 'sm';
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '@astryxdesign/core/Icon';
|
|
3
|
+
import { ToggleButton } from '@astryxdesign/core/ToggleButton';
|
|
4
|
+
import { IconMicrophone, IconMicrophoneOff } from '@tabler/icons-react';
|
|
5
|
+
import { useLabels } from "./labels-provider.js";
|
|
6
|
+
/** The microphone toggle every live view draws. A slash on the icon means a click mutes. */
|
|
7
|
+
export function LiveMicToggle({ call, size }) {
|
|
8
|
+
const t = useLabels();
|
|
9
|
+
return (_jsx(ToggleButton, { label: t('@theorem.live.microphone'), tooltip: t(call.isMuted ? '@theorem.live.unmute' : '@theorem.live.mute'), isIconOnly: true, ...(size ? { size } : {}), isPressed: !call.isMuted, isDisabled: !call.sessionActive, icon: _jsx(Icon, { icon: IconMicrophone }), pressedIcon: _jsx(Icon, { icon: IconMicrophoneOff }), onPressedChange: call.handleToggleMic }));
|
|
10
|
+
}
|
package/ui/LiveRunner.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import type { DefinedTheme } from '@astryxdesign/core/theme';
|
|
2
2
|
import type { LiveCall } from '../components/live/use-live-call.js';
|
|
3
3
|
import { type TheoremLabels } from './labels.js';
|
|
4
|
+
import { type LiveControlsSlot, type LiveSlot, type LiveVideoPreviewOptions } from './live-slots.js';
|
|
4
5
|
import { type TheoremChatProps } from './TheoremChat.js';
|
|
6
|
+
/** The parts of `LiveRunner` a host can change; see {@link LiveSlot}. */
|
|
7
|
+
export type LiveRunnerSlots = {
|
|
8
|
+
/** Before a call: the greeting and the call buttons. */
|
|
9
|
+
landing?: LiveSlot;
|
|
10
|
+
/** The agent's name and the call's state, over the waveform. */
|
|
11
|
+
header?: LiveSlot;
|
|
12
|
+
/** The failure and session-ended banners. */
|
|
13
|
+
notices?: LiveSlot;
|
|
14
|
+
waveform?: LiveSlot;
|
|
15
|
+
controls?: LiveControlsSlot;
|
|
16
|
+
/** The captions panel's content. `null` also removes the panel and its toggle. */
|
|
17
|
+
captions?: LiveSlot;
|
|
18
|
+
/** The tool gate dialog. */
|
|
19
|
+
gate?: LiveSlot;
|
|
20
|
+
};
|
|
5
21
|
/** `media`, `resolveMedia` and `mediaViewer` are the chat's: the captions show a tool's media as the chat does. */
|
|
6
22
|
export type LiveRunnerProps = Pick<TheoremChatProps, 'media' | 'resolveMedia' | 'mediaViewer'> & {
|
|
7
23
|
/** The call to draw, from `useLiveCall`. The call outlives the runner: it ends when its owner unmounts. */
|
|
@@ -24,6 +40,11 @@ export type LiveRunnerProps = Pick<TheoremChatProps, 'media' | 'resolveMedia' |
|
|
|
24
40
|
* the control.
|
|
25
41
|
*/
|
|
26
42
|
onMinimize?: () => void;
|
|
43
|
+
slots?: LiveRunnerSlots;
|
|
44
|
+
/** How the camera preview is drawn, and what is drawn over it. */
|
|
45
|
+
video?: LiveVideoPreviewOptions;
|
|
46
|
+
/** Whether the captions panel starts open. Default `true`. */
|
|
47
|
+
captionsDefaultOpen?: boolean;
|
|
27
48
|
};
|
|
28
49
|
/**
|
|
29
50
|
* Live (voice / video) runner on Astryx. Before a call: a landing like the
|
package/ui/LiveRunner.js
CHANGED
|
@@ -11,14 +11,16 @@ import { Text } from '@astryxdesign/core/Text';
|
|
|
11
11
|
import { ToggleButton } from '@astryxdesign/core/ToggleButton';
|
|
12
12
|
import { Toolbar } from '@astryxdesign/core/Toolbar';
|
|
13
13
|
import { VStack } from '@astryxdesign/core/VStack';
|
|
14
|
-
import { IconArrowsDiagonalMinimize2, IconCameraRotate, IconMessage,
|
|
14
|
+
import { IconArrowsDiagonalMinimize2, IconCamera, IconCameraRotate, IconMessage, IconPhone, IconPhoneOff, IconVideo, IconVideoOff, } from '@tabler/icons-react';
|
|
15
15
|
import { Fragment, useLayoutEffect, useRef } from 'react';
|
|
16
16
|
import { InkWaveform } from "../components/InkWaveform.js";
|
|
17
17
|
import { LiveCaptionsPanel } from "./LiveCaptionsPanel.js";
|
|
18
|
+
import { LiveMicToggle } from "./LiveMicToggle.js";
|
|
18
19
|
import { LiveToolGateDialog } from "./LiveToolGateDialog.js";
|
|
19
20
|
import { LiveVideoPreview } from "./LiveVideoPreview.js";
|
|
20
21
|
import { liveStateLabel } from "./labels.js";
|
|
21
22
|
import { useLabels } from "./labels-provider.js";
|
|
23
|
+
import { liveControlIds, renderLiveControls, renderLiveSlot, } from "./live-slots.js";
|
|
22
24
|
import { PANEL_EDGE, SidePanel, SidePanelHeader, SidePanelToggle, useSidePanel, } from "./SidePanel.js";
|
|
23
25
|
import { DEFAULT_CHAT_MAX_WIDTH } from "./TheoremChat.js";
|
|
24
26
|
import { TheoremSurface } from "./TheoremSurface.js";
|
|
@@ -36,23 +38,24 @@ const WAVE_HEIGHT = 320;
|
|
|
36
38
|
export function LiveRunner({ theme, mode, labels, media, resolveMedia, mediaViewer, ...props }) {
|
|
37
39
|
return (_jsx(TheoremSurface, { theme: theme, mode: mode, labels: labels, detectCodeLanguage: undefined, media: media, resolveMedia: resolveMedia, mediaViewer: mediaViewer, children: _jsx(LiveRunnerBody, { ...props }) }));
|
|
38
40
|
}
|
|
39
|
-
function LiveRunnerBody({ call, trace, onMinimize, }) {
|
|
41
|
+
function LiveRunnerBody({ call, trace, onMinimize, slots = {}, video, captionsDefaultOpen = true, }) {
|
|
40
42
|
const t = useLabels();
|
|
41
43
|
// why: Both panels size against the whole live layout, so a third means the same for each.
|
|
42
44
|
const layoutRef = useRef(null);
|
|
43
45
|
const inspector = useTraceInspector(call.iface, call.traces, trace);
|
|
44
|
-
const captions = useSidePanel(layoutRef,
|
|
46
|
+
const captions = useSidePanel(layoutRef, captionsDefaultOpen);
|
|
47
|
+
const hasCaptions = slots.captions !== null;
|
|
45
48
|
const captionLabels = {
|
|
46
49
|
name: t('@theorem.panel.captions.name'),
|
|
47
50
|
show: t('@theorem.panel.captions.show'),
|
|
48
51
|
hide: t('@theorem.panel.captions.hide'),
|
|
49
52
|
resize: t('@theorem.panel.captions.resize'),
|
|
50
53
|
};
|
|
51
|
-
const captionsToggle = (_jsx(SidePanelToggle, { labels: captionLabels, icon: _jsx(Icon, { icon: IconMessage }), panelId: captions.id, open: captions.open, onToggle: captions.toggle }));
|
|
54
|
+
const captionsToggle = hasCaptions ? (_jsx(SidePanelToggle, { labels: captionLabels, icon: _jsx(Icon, { icon: IconMessage }), panelId: captions.id, open: captions.open, onToggle: captions.toggle })) : null;
|
|
52
55
|
if (!call.callStarted) {
|
|
53
|
-
return (_jsx(WithTrace, { inspector: inspector, children: _jsx(Layout, { ref: layoutRef, height: "fill", header: _jsx(SidePanelHeader, { children: inspector.toggle }), content: _jsx(LayoutContent, { padding: 0, children: _jsx(LiveLanding, { call: call }) }) }) }));
|
|
56
|
+
return (_jsx(WithTrace, { inspector: inspector, children: _jsx(Layout, { ref: layoutRef, height: "fill", header: _jsx(SidePanelHeader, { children: inspector.toggle }), content: _jsx(LayoutContent, { padding: 0, children: renderLiveSlot(slots.landing, call, _jsx(LiveLanding, { call: call })) }) }) }));
|
|
54
57
|
}
|
|
55
|
-
return (_jsxs(_Fragment, { children: [_jsx(WithTrace, { inspector: inspector, children: _jsx(Layout, { ref: layoutRef, height: "fill", header: _jsx(SidePanelHeader, { children: inspector.toggle }), content: _jsx(LayoutContent, { padding: 0, children: _jsx(Layout, { height: "fill", end: _jsx(SidePanel, { id: captions.id, labels: captionLabels, resizable: captions.resizable, open: captions.open, children: _jsx(LiveCaptions, { call: call }) }), content: _jsx(LayoutContent, { padding: 0, children: _jsx(VStack, { height: "100%", padding: PANEL_EDGE, children: _jsx(LiveStage, { call: call, captionsToggle: captionsToggle, onMinimize: onMinimize }) }) }) }) }) }) }), _jsx(LiveToolGateDialog, { call: call })] }));
|
|
58
|
+
return (_jsxs(_Fragment, { children: [_jsx(WithTrace, { inspector: inspector, children: _jsx(Layout, { ref: layoutRef, height: "fill", header: _jsx(SidePanelHeader, { children: inspector.toggle }), content: _jsx(LayoutContent, { padding: 0, children: _jsx(Layout, { height: "fill", end: hasCaptions ? (_jsx(SidePanel, { id: captions.id, labels: captionLabels, resizable: captions.resizable, open: captions.open, children: renderLiveSlot(slots.captions, call, _jsx(LiveCaptions, { call: call, video: video })) })) : undefined, content: _jsx(LayoutContent, { padding: 0, children: _jsx(VStack, { height: "100%", padding: PANEL_EDGE, children: _jsx(LiveStage, { call: call, captionsToggle: captionsToggle, onMinimize: onMinimize, slots: slots }) }) }) }) }) }) }), renderLiveSlot(slots.gate, call, _jsx(LiveToolGateDialog, { call: call }))] }));
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* Before a call: the chat landing's greeting, with call buttons where the
|
|
@@ -66,10 +69,14 @@ function LiveLanding({ call }) {
|
|
|
66
69
|
* The agent tag and state over the resting waveform, then the call controls,
|
|
67
70
|
* all in one column the waveform's width.
|
|
68
71
|
*/
|
|
69
|
-
function LiveStage({ call, captionsToggle, onMinimize, }) {
|
|
72
|
+
function LiveStage({ call, captionsToggle, onMinimize, slots, }) {
|
|
70
73
|
const t = useLabels();
|
|
71
74
|
const ref = useEnterMotion();
|
|
72
|
-
return (_jsx(VStack, { ref: ref, height: "100%", hAlign: "center", children: _jsxs(VStack, { width: "100%", maxWidth: WAVE_MAX_WIDTH, height: "100%", gap: 3, children: [_jsxs(VStack, { gap: 0.5, children: [_jsx(Text, { type: "label", color: "secondary", children: t('@theorem.agent.handle', { handle: call.handle }) }), _jsx(Text, { size: "sm", color: "secondary", children: liveStateLabel(t, call.liveState, call.activeTool) })] }),
|
|
75
|
+
return (_jsx(VStack, { ref: ref, height: "100%", hAlign: "center", children: _jsxs(VStack, { width: "100%", maxWidth: WAVE_MAX_WIDTH, height: "100%", gap: 3, children: [renderLiveSlot(slots.header, call, _jsxs(VStack, { gap: 0.5, children: [_jsx(Text, { type: "label", color: "secondary", children: t('@theorem.agent.handle', { handle: call.handle }) }), _jsx(Text, { size: "sm", color: "secondary", children: liveStateLabel(t, call.liveState, call.activeTool) })] })), renderLiveSlot(slots.notices, call, _jsx(LiveNotices, { call: call })), _jsx(StackItem, { size: "fill", children: _jsx(VStack, { height: "100%", vAlign: "end", children: renderLiveSlot(slots.waveform, call, _jsx(VStack, { width: "100%", height: WAVE_HEIGHT, style: { color: 'var(--color-icon-primary)' }, "aria-hidden": "true", children: _jsx(InkWaveform, { status: call.status, levelsRef: call.levelsRef, toolActive: call.toolActive, variant: "hero" }) })) }) }), slots.controls === null ? null : (_jsx(LiveControls, { call: call, captionsToggle: captionsToggle, onMinimize: onMinimize, slot: slots.controls }))] }) }));
|
|
76
|
+
}
|
|
77
|
+
/** The failure and session-ended banners. */
|
|
78
|
+
function LiveNotices({ call }) {
|
|
79
|
+
return (_jsxs(_Fragment, { children: [call.failure ? _jsx(Banner, { status: "error", role: "alert", title: call.failure.error }) : null, call.sessionEnded ? _jsx(Banner, { status: "info", role: "status", title: call.sessionEnded }) : null] }));
|
|
73
80
|
}
|
|
74
81
|
/**
|
|
75
82
|
* Eases the call view in from the landing: Astryx has no enter-transition
|
|
@@ -94,20 +101,25 @@ function useEnterMotion() {
|
|
|
94
101
|
* Mic, camera, captions, and call controls, centred under the stage. Icons show
|
|
95
102
|
* what a click does, as End call does: a slash means "turn this off".
|
|
96
103
|
*/
|
|
97
|
-
function LiveControls({ call, captionsToggle, onMinimize, }) {
|
|
104
|
+
function LiveControls({ call, captionsToggle, onMinimize, slot, }) {
|
|
98
105
|
const t = useLabels();
|
|
99
106
|
const inactive = !call.sessionActive;
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
const parts = {
|
|
108
|
+
mic: () => _jsx(LiveMicToggle, { call: call }, "mic"),
|
|
109
|
+
video: () => _jsx(LiveVideoControls, { call: call }, "video"),
|
|
110
|
+
snapshot: () => (_jsx(IconButton, { label: t('@theorem.live.snapshot'), tooltip: t('@theorem.live.snapshot'), variant: "ghost", isDisabled: inactive, icon: _jsx(Icon, { icon: IconCamera }), onClick: call.handleSnapshot }, "snapshot")),
|
|
111
|
+
minimize: () => (_jsx(IconButton, { label: t('@theorem.live.minimize'), tooltip: t('@theorem.live.minimize'), variant: "ghost", icon: _jsx(Icon, { icon: IconArrowsDiagonalMinimize2 }), onClick: onMinimize }, "minimize")),
|
|
112
|
+
captions: () => _jsx(Fragment, { children: captionsToggle }, "captions"),
|
|
113
|
+
call: () => _jsx(LiveCallButton, { call: call }, "call"),
|
|
114
|
+
};
|
|
115
|
+
const ids = liveControlIds(call, {
|
|
116
|
+
minimize: onMinimize !== undefined,
|
|
117
|
+
captions: captionsToggle !== null,
|
|
118
|
+
expand: false,
|
|
119
|
+
snapshot: call.snapshotAvailable && call.isVideoOn,
|
|
120
|
+
});
|
|
121
|
+
const controls = ids.map((id) => ({ id, node: parts[id]?.() ?? null }));
|
|
122
|
+
return (_jsx(Toolbar, { label: t('@theorem.live.controls'), dividers: ['top'], centerContent: _jsx(HStack, { gap: 2, vAlign: "center", children: renderLiveControls(slot, call, controls) }) }));
|
|
111
123
|
}
|
|
112
124
|
/** The camera toggle, and the flip control while the camera is on. */
|
|
113
125
|
function LiveVideoControls({ call }) {
|
|
@@ -130,6 +142,6 @@ function LiveCallButton({ call }) {
|
|
|
130
142
|
* Captions drawn by the chat's own transcript, with the text composer in its
|
|
131
143
|
* dock when the profile takes text.
|
|
132
144
|
*/
|
|
133
|
-
function LiveCaptions({ call }) {
|
|
134
|
-
return (_jsx(LiveCaptionsPanel, { handle: call.handle, captions: call.captions, pastCalls: call.pastCalls, draftText: call.textDraft, onDraftTextChange: call.setTextDraft, onSubmit: call.handleSendText, isDisabled: !call.sessionActive, showComposer: call.textAvailable, leading: call.videoPreview ? (_jsx(LiveVideoPreview, { video: call.videoPreview, facingMode: call.videoFacingMode })) : null }));
|
|
145
|
+
function LiveCaptions({ call, video, }) {
|
|
146
|
+
return (_jsx(LiveCaptionsPanel, { handle: call.handle, captions: call.captions, pastCalls: call.pastCalls, draftText: call.textDraft, onDraftTextChange: call.setTextDraft, onSubmit: call.handleSendText, isDisabled: !call.sessionActive, showComposer: call.textAvailable, leading: call.videoPreview ? (_jsx(LiveVideoPreview, { ...video, video: call.videoPreview, facingMode: call.videoFacingMode })) : null }));
|
|
135
147
|
}
|
package/ui/LiveVideoPreview.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import type { LiveFacingMode } from '../client/live/live-video.js';
|
|
2
|
+
import type { LiveVideoFit, LiveVideoOverlay } from '../client/live/live-video-view.js';
|
|
3
|
+
export type LiveVideoPreviewProps = {
|
|
4
|
+
video: HTMLVideoElement;
|
|
5
|
+
facingMode: LiveFacingMode;
|
|
6
|
+
/** The box's width over its height. Default `4 / 3`. */
|
|
7
|
+
aspectRatio?: number;
|
|
8
|
+
/** How the picture fills the box. Default `cover`. */
|
|
9
|
+
fit?: LiveVideoFit;
|
|
10
|
+
/** `false` never mirrors the user-facing camera. Default `true`. */
|
|
11
|
+
mirrorUserCamera?: boolean;
|
|
12
|
+
/** Drawn over the picture; see {@link LiveVideoOverlay}. */
|
|
13
|
+
overlay?: LiveVideoOverlay;
|
|
14
|
+
};
|
|
2
15
|
/**
|
|
3
16
|
* The camera preview: atop the call's captions, or in its tile. The capture element comes
|
|
4
|
-
* from the session client, so it is mounted imperatively; it
|
|
5
|
-
*
|
|
17
|
+
* from the session client, so it is mounted imperatively; it carries its own fill and mirror
|
|
18
|
+
* styles. The overlay is a sibling of its host, so mounting the element never removes it.
|
|
6
19
|
*/
|
|
7
|
-
export declare function LiveVideoPreview({ video, facingMode, }:
|
|
8
|
-
video: HTMLVideoElement;
|
|
9
|
-
facingMode: LiveFacingMode;
|
|
10
|
-
}): import("react").JSX.Element;
|
|
20
|
+
export declare function LiveVideoPreview({ video, facingMode, aspectRatio, fit, mirrorUserCamera, overlay, }: LiveVideoPreviewProps): import("react").JSX.Element;
|
package/ui/LiveVideoPreview.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AspectRatio } from '@astryxdesign/core/AspectRatio';
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { useLabels } from "./labels-provider.js";
|
|
5
|
+
const FILL = { position: 'relative', width: '100%', height: '100%' };
|
|
6
|
+
const HOST = { width: '100%', height: '100%' };
|
|
7
|
+
const OVER = { position: 'absolute', inset: 0, pointerEvents: 'none' };
|
|
5
8
|
/**
|
|
6
9
|
* The camera preview: atop the call's captions, or in its tile. The capture element comes
|
|
7
|
-
* from the session client, so it is mounted imperatively; it
|
|
8
|
-
*
|
|
10
|
+
* from the session client, so it is mounted imperatively; it carries its own fill and mirror
|
|
11
|
+
* styles. The overlay is a sibling of its host, so mounting the element never removes it.
|
|
9
12
|
*/
|
|
10
|
-
export function LiveVideoPreview({ video, facingMode, }) {
|
|
13
|
+
export function LiveVideoPreview({ video, facingMode, aspectRatio = 4 / 3, fit = 'cover', mirrorUserCamera = true, overlay, }) {
|
|
11
14
|
const t = useLabels();
|
|
12
15
|
const hostRef = useRef(null);
|
|
16
|
+
const mirrored = mirrorUserCamera && facingMode === 'user';
|
|
17
|
+
const frame = useFrameSize(video);
|
|
13
18
|
useEffect(() => {
|
|
14
19
|
const host = hostRef.current;
|
|
15
20
|
if (!host)
|
|
16
21
|
return;
|
|
17
|
-
Object.assign(video.style, {
|
|
18
|
-
width: '100%',
|
|
19
|
-
height: '100%',
|
|
20
|
-
objectFit: 'cover',
|
|
21
|
-
display: 'block',
|
|
22
|
-
});
|
|
22
|
+
Object.assign(video.style, { width: '100%', height: '100%', display: 'block' });
|
|
23
23
|
host.replaceChildren(video);
|
|
24
24
|
return () => {
|
|
25
25
|
if (video.parentElement === host)
|
|
@@ -27,7 +27,28 @@ export function LiveVideoPreview({ video, facingMode, }) {
|
|
|
27
27
|
};
|
|
28
28
|
}, [video]);
|
|
29
29
|
useEffect(() => {
|
|
30
|
-
video.style.
|
|
31
|
-
}, [video,
|
|
32
|
-
|
|
30
|
+
video.style.objectFit = fit;
|
|
31
|
+
}, [video, fit]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
video.style.transform = mirrored ? 'scaleX(-1)' : '';
|
|
34
|
+
}, [video, mirrored]);
|
|
35
|
+
return (_jsx(AspectRatio, { ratio: aspectRatio, fit: "cover", children: _jsxs("div", { style: FILL, children: [_jsx("div", { ref: hostRef, style: HOST, "aria-label": t('@theorem.live.camera_preview'), role: "img" }), overlay ? (_jsx("div", { style: OVER, children: overlay({ video, ...frame, facingMode, mirrored, fit, aspectRatio }) })) : null] }) }));
|
|
36
|
+
}
|
|
37
|
+
/** The camera picture's size, kept current when the first picture comes and when it changes, as on a flip. */
|
|
38
|
+
function useFrameSize(video) {
|
|
39
|
+
const [size, setSize] = useState({
|
|
40
|
+
frameWidth: video.videoWidth,
|
|
41
|
+
frameHeight: video.videoHeight,
|
|
42
|
+
});
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const read = () => setSize({ frameWidth: video.videoWidth, frameHeight: video.videoHeight });
|
|
45
|
+
read();
|
|
46
|
+
video.addEventListener('loadedmetadata', read);
|
|
47
|
+
video.addEventListener('resize', read);
|
|
48
|
+
return () => {
|
|
49
|
+
video.removeEventListener('loadedmetadata', read);
|
|
50
|
+
video.removeEventListener('resize', read);
|
|
51
|
+
};
|
|
52
|
+
}, [video]);
|
|
53
|
+
return size;
|
|
33
54
|
}
|
package/ui/TheoremChat.d.ts
CHANGED
|
@@ -157,6 +157,8 @@ export type TheoremChatProps = {
|
|
|
157
157
|
refText?: RefText;
|
|
158
158
|
/** Draws a ref, as a chip in the composer and in the person's message. */
|
|
159
159
|
renderRef?: (ref: UserRef) => ReactNode;
|
|
160
|
+
/** Stands in for the send button while the composer is empty; see `ChatComposerBarProps.emptyAction`. */
|
|
161
|
+
composerEmptyAction?: ReactNode;
|
|
160
162
|
};
|
|
161
163
|
/** What a host can do to a mounted {@link TheoremChat}. */
|
|
162
164
|
export type TheoremChatHandle = {
|
|
@@ -200,13 +202,15 @@ export type TheoremChatComposerProps = {
|
|
|
200
202
|
renderRef?: (ref: UserRef) => ReactNode;
|
|
201
203
|
/** The app's own pills, in the `row` layout's pill row after the background jobs. */
|
|
202
204
|
pills?: readonly ComposerPill[];
|
|
205
|
+
/** Stands in for the send button while the composer is empty; see `ChatComposerBarProps.emptyAction`. */
|
|
206
|
+
emptyAction?: ReactNode;
|
|
203
207
|
};
|
|
204
208
|
/**
|
|
205
209
|
* The composer bound to a chat: drafts, files, voice, the pending queue, send and stop, and the
|
|
206
210
|
* working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
|
|
207
211
|
* `TheoremChatTranscript`.
|
|
208
212
|
*/
|
|
209
|
-
export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, }: TheoremChatComposerProps): import("react").JSX.Element;
|
|
213
|
+
export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, }: TheoremChatComposerProps): import("react").JSX.Element;
|
|
210
214
|
export type TheoremChatTranscriptProps = Omit<ChatTranscriptProps, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
|
|
211
215
|
/** The chat it shows (`useTheoremChat`). */
|
|
212
216
|
chat: TheoremChatState;
|
package/ui/TheoremChat.js
CHANGED
|
@@ -33,8 +33,8 @@ function ChatColumn({ maxWidth, ref, children, }) {
|
|
|
33
33
|
* working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
|
|
34
34
|
* `TheoremChatTranscript`.
|
|
35
35
|
*/
|
|
36
|
-
export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, }) {
|
|
37
|
-
return (_jsx(ChatComposerBar, { iface: iface, layout: layout, icons: icons, pills: pills, workingSince: chat.workingSince, backgroundJobs: chat.backgroundJobs, draftText: chat.draftText, pendingFiles: chat.pendingFiles, pendingVoice: chat.pendingVoice, pendingMessages: chat.pendingMessages, issues: chat.issues, phase: chat.phase, failure: chat.failure, selectedModel: chat.session.selectedModel, selectedEffort: chat.session.selectedEffort, placeholder: placeholder, inputRef: inputRef, inputComponent: inputComponent, triggers: triggers, refText: refText, renderRef: renderRef, draftParts: chat.draftParts, onDraftPartsChange: chat.setDraftParts, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
|
|
36
|
+
export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, }) {
|
|
37
|
+
return (_jsx(ChatComposerBar, { emptyAction: emptyAction, iface: iface, layout: layout, icons: icons, pills: pills, workingSince: chat.workingSince, backgroundJobs: chat.backgroundJobs, draftText: chat.draftText, pendingFiles: chat.pendingFiles, pendingVoice: chat.pendingVoice, pendingMessages: chat.pendingMessages, issues: chat.issues, phase: chat.phase, failure: chat.failure, selectedModel: chat.session.selectedModel, selectedEffort: chat.session.selectedEffort, placeholder: placeholder, inputRef: inputRef, inputComponent: inputComponent, triggers: triggers, refText: refText, renderRef: renderRef, draftParts: chat.draftParts, onDraftPartsChange: chat.setDraftParts, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
|
|
38
38
|
chat.setPendingFiles((prev) => [...prev, ...files]);
|
|
39
39
|
chat.setIssues([]);
|
|
40
40
|
}, onAttachmentRemove: (index) => {
|
|
@@ -69,13 +69,14 @@ function useChatHandle(chatRef, chat) {
|
|
|
69
69
|
return inputRef;
|
|
70
70
|
}
|
|
71
71
|
/** The composer, or, with none, the failed turn's error where the composer was. */
|
|
72
|
-
function ChatBodyComposer({
|
|
73
|
-
if (
|
|
74
|
-
return _jsx(TheoremChatComposer, {
|
|
75
|
-
const failure =
|
|
72
|
+
function ChatBodyComposer({ body, chat, inputRef, }) {
|
|
73
|
+
if (body.composer ?? true)
|
|
74
|
+
return (_jsx(TheoremChatComposer, { chat: chat, iface: body.iface, placeholder: body.placeholder, inputRef: inputRef, layout: body.composerLayout, icons: body.composerIcons, inputComponent: body.composerInput, triggers: body.composerTriggers, refText: body.refText, renderRef: body.renderRef, emptyAction: body.composerEmptyAction }));
|
|
75
|
+
const failure = chat.failure;
|
|
76
76
|
return failure ? _jsx(Banner, { status: "error", role: "alert", title: failure.error }) : null;
|
|
77
77
|
}
|
|
78
|
-
function ChatBody(
|
|
78
|
+
function ChatBody(props) {
|
|
79
|
+
const { transport, iface, emptyState, density, maxWidth = DEFAULT_CHAT_MAX_WIDTH, scrollRef, trace, usage, className, style, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, refText, renderRef, options, onOptionsChange, stated, context, pageTools, onTurnEvent, } = props;
|
|
79
80
|
const t = useLabels();
|
|
80
81
|
const chat = useTheoremChat({
|
|
81
82
|
transport,
|
|
@@ -101,7 +102,7 @@ function ChatBody({ transport, iface, placeholder, emptyState, density, maxWidth
|
|
|
101
102
|
const composerRef = useGlide(landing, () => inputRef.current?.focus());
|
|
102
103
|
const inspector = useTraceInspector(iface, transport.traces, trace);
|
|
103
104
|
const header = _jsx(SidePanelHeader, { floating: true, children: inspector.toggle });
|
|
104
|
-
const composer =
|
|
105
|
+
const composer = _jsx(ChatBodyComposer, { body: props, chat: chat, inputRef: inputRef });
|
|
105
106
|
const docked = { composer, composerRef, maxWidth };
|
|
106
107
|
return (_jsx(WithTrace, { inspector: inspector, children: _jsx(Layout, { height: "fill", className: className, style: { position: 'relative', ...style }, header: header, content: _jsx(LayoutContent, { padding: 0, isScrollable: landing, children: landing ? (_jsx(ChatLanding, { ...docked, handle: handle, emptyState: emptyState })) : (_jsx(ChatThread, { ...docked, chat: chat, iface: iface, handle: handle, density: density, scrollRef: scrollRef, usage: usage, renderRef: renderRef })) }) }) }));
|
|
107
108
|
}
|
package/ui/arrive.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export declare function useArrive(): {
|
|
|
15
15
|
/** A block that eases in with its siblings under {@link Stream}. */
|
|
16
16
|
export declare function Arrive({ children }: {
|
|
17
17
|
children: ReactNode;
|
|
18
|
-
}): string | number | bigint | boolean |
|
|
18
|
+
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|