@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/ui/labels.d.ts CHANGED
@@ -1444,6 +1444,10 @@ export declare const THEOREM_UI_CATALOG: {
1444
1444
  readonly defaultMessage: "Flip camera";
1445
1445
  readonly description: "Switches front and back camera.";
1446
1446
  };
1447
+ readonly '@theorem.live.snapshot': {
1448
+ readonly defaultMessage: "Snapshot";
1449
+ readonly description: "Hands the camera picture to the host, which decides what happens with it.";
1450
+ };
1447
1451
  readonly '@theorem.live.end_call': {
1448
1452
  readonly defaultMessage: "End call";
1449
1453
  readonly description: "Hangs up.";
package/ui/labels.js CHANGED
@@ -1374,6 +1374,10 @@ export const THEOREM_UI_CATALOG = {
1374
1374
  defaultMessage: 'Flip camera',
1375
1375
  description: 'Switches front and back camera.',
1376
1376
  },
1377
+ '@theorem.live.snapshot': {
1378
+ defaultMessage: 'Snapshot',
1379
+ description: 'Hands the camera picture to the host, which decides what happens with it.',
1380
+ },
1377
1381
  '@theorem.live.end_call': { defaultMessage: 'End call', description: 'Hangs up.' },
1378
1382
  '@theorem.live.expand': {
1379
1383
  defaultMessage: 'Open call',
@@ -0,0 +1,43 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { LiveVideoFit, LiveVideoOverlay } from '../client/live/live-video-view.js';
3
+ import type { LiveCall } from '../components/live/use-live-call.js';
4
+ /**
5
+ * A part of a live view the host can change. Left out, Theorem draws its own part. `null` draws
6
+ * nothing there. A function is drawn in its place: it gets the call and Theorem's part, to keep,
7
+ * wrap, or leave out.
8
+ */
9
+ export type LiveSlot = null | ((call: LiveCall, standard: ReactNode) => ReactNode);
10
+ /** The controls a live view draws, by name. */
11
+ export type LiveControlId = 'mic' | 'video' | 'snapshot' | 'minimize' | 'captions' | 'call' | 'expand';
12
+ /** One of Theorem's call controls, for a host that reorders, drops, or adds to them. */
13
+ export type LiveControl = {
14
+ id: LiveControlId;
15
+ node: ReactNode;
16
+ };
17
+ /**
18
+ * The call controls. Left out, Theorem's controls are drawn in their order. `null` draws no
19
+ * controls. A function gets the call and Theorem's controls, and its answer is drawn where they go.
20
+ */
21
+ export type LiveControlsSlot = null | ((call: LiveCall, controls: readonly LiveControl[]) => ReactNode);
22
+ /** How a live view draws the camera preview. Each field left out keeps Theorem's. */
23
+ export type LiveVideoPreviewOptions = {
24
+ /** The preview box's width over its height. Default `4 / 3`. */
25
+ aspectRatio?: number;
26
+ /** Default `cover`. */
27
+ fit?: LiveVideoFit;
28
+ /** `false` never mirrors the user-facing camera. Default `true`. */
29
+ mirrorUserCamera?: boolean;
30
+ /** Drawn over the picture, such as marks the model placed on the frame. */
31
+ overlay?: LiveVideoOverlay;
32
+ };
33
+ /** What a slot draws: Theorem's part when left out, nothing for `null`, else the host's. */
34
+ export declare function renderLiveSlot(slot: LiveSlot | undefined, call: LiveCall, standard: ReactNode): ReactNode;
35
+ /** What the controls slot draws, as `renderLiveSlot` does for one part. */
36
+ export declare function renderLiveControls(slot: LiveControlsSlot | undefined, call: LiveCall, controls: readonly LiveControl[]): ReactNode;
37
+ /** The controls a call shows, in Theorem's order. */
38
+ export declare function liveControlIds(call: Pick<LiveCall, 'voiceAvailable' | 'videoAvailable'>, has: {
39
+ minimize: boolean;
40
+ captions: boolean;
41
+ expand: boolean;
42
+ snapshot?: boolean;
43
+ }): LiveControlId[];
@@ -0,0 +1,34 @@
1
+ /** What a slot draws: Theorem's part when left out, nothing for `null`, else the host's. */
2
+ export function renderLiveSlot(slot, call, standard) {
3
+ if (slot === undefined)
4
+ return standard;
5
+ if (slot === null)
6
+ return null;
7
+ return slot(call, standard);
8
+ }
9
+ /** What the controls slot draws, as `renderLiveSlot` does for one part. */
10
+ export function renderLiveControls(slot, call, controls) {
11
+ if (slot === undefined)
12
+ return controls.map((control) => control.node);
13
+ if (slot === null)
14
+ return null;
15
+ return slot(call, controls);
16
+ }
17
+ /** The controls a call shows, in Theorem's order. */
18
+ export function liveControlIds(call, has) {
19
+ const ids = [];
20
+ if (call.voiceAvailable)
21
+ ids.push('mic');
22
+ if (call.videoAvailable)
23
+ ids.push('video');
24
+ if (call.videoAvailable && has.snapshot)
25
+ ids.push('snapshot');
26
+ if (has.minimize)
27
+ ids.push('minimize');
28
+ if (has.captions)
29
+ ids.push('captions');
30
+ ids.push('call');
31
+ if (has.expand)
32
+ ids.push('expand');
33
+ return ids;
34
+ }