@equos/react 3.0.2-rc.1 → 3.0.2-rc.10
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/dist/components/equos-character-tile.d.ts +12 -0
- package/dist/components/equos-character-tile.js +82 -0
- package/dist/{src/components → components}/equos-conversation-renderer.d.ts +4 -1
- package/dist/{src/components → components}/equos-conversation-renderer.js +6 -5
- package/dist/components/equos-hangup-button.js +9 -0
- package/dist/{src/components → components}/equos-video-tile.js +5 -2
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +24 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/styles.css +745 -0
- package/dist/utils/copy.utils.d.ts +24 -0
- package/dist/utils/copy.utils.js +273 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/{src → utils}/index.js +1 -1
- package/package.json +8 -7
- package/dist/src/components/equos-character-video.d.ts +0 -4
- package/dist/src/components/equos-character-video.js +0 -27
- package/dist/src/components/equos-hangup-button.js +0 -9
- package/dist/src/index.d.ts +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{src/client.d.ts → client.d.ts} +0 -0
- /package/dist/{src/client.js → client.js} +0 -0
- /package/dist/{src/components → components}/equos-camera-toggle.d.ts +0 -0
- /package/dist/{src/components → components}/equos-camera-toggle.js +0 -0
- /package/dist/{src/components → components}/equos-hangup-button.d.ts +0 -0
- /package/dist/{src/components → components}/equos-logo.d.ts +0 -0
- /package/dist/{src/components → components}/equos-logo.js +0 -0
- /package/dist/{src/components → components}/equos-mic-toggle.d.ts +0 -0
- /package/dist/{src/components → components}/equos-mic-toggle.js +0 -0
- /package/dist/{src/components → components}/equos-screenshare-toggle.d.ts +0 -0
- /package/dist/{src/components → components}/equos-screenshare-toggle.js +0 -0
- /package/dist/{src/components → components}/equos-video-tile.d.ts +0 -0
- /package/dist/{src/utils → utils}/cn.d.ts +0 -0
- /package/dist/{src/utils → utils}/cn.js +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EquosLocale } from '../utils/copy.utils';
|
|
2
|
+
export declare function EquosCharacterTile({ identity, name, locale, className, startedAt, maxSeconds, recoveryTimeInSeconds, showTimeLeft, onShouldLeave, }: {
|
|
3
|
+
identity: string;
|
|
4
|
+
name: string;
|
|
5
|
+
locale?: EquosLocale;
|
|
6
|
+
className?: string;
|
|
7
|
+
startedAt: Date;
|
|
8
|
+
maxSeconds: number;
|
|
9
|
+
recoveryTimeInSeconds?: number;
|
|
10
|
+
showTimeLeft?: boolean;
|
|
11
|
+
onShouldLeave?: () => void | Promise<void>;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EquosCharacterTile = EquosCharacterTile;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const components_react_1 = require("@livekit/components-react");
|
|
6
|
+
const cn_1 = require("../utils/cn");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const livekit_client_1 = require("livekit-client");
|
|
9
|
+
const copy_utils_1 = require("../utils/copy.utils");
|
|
10
|
+
function EquosCharacterTile({ identity, name, locale = copy_utils_1.EquosLocale.EN, className, startedAt, maxSeconds, recoveryTimeInSeconds = 3, showTimeLeft = true, onShouldLeave, }) {
|
|
11
|
+
const waitForCharacterToJoin = 20;
|
|
12
|
+
const [joined, setJoined] = (0, react_1.useState)(false);
|
|
13
|
+
const [leftTimeout, setLeftTimeout] = (0, react_1.useState)(null);
|
|
14
|
+
const [remainingTime, setRemainingTime] = (0, react_1.useState)(null);
|
|
15
|
+
const [duration, setDuration] = (0, react_1.useState)(0);
|
|
16
|
+
const participants = (0, components_react_1.useParticipants)();
|
|
17
|
+
const trackRef = (0, react_1.useMemo)(() => {
|
|
18
|
+
const participant = participants.find((p) => p.identity === identity);
|
|
19
|
+
if (!participant || !participant.trackPublications) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const publication = Array.from(participant.trackPublications.values()).find((pub) => pub.source === livekit_client_1.Track.Source.Camera);
|
|
23
|
+
if (!publication) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
participant,
|
|
28
|
+
publication,
|
|
29
|
+
source: livekit_client_1.Track.Source.Camera,
|
|
30
|
+
};
|
|
31
|
+
}, [identity, participants]);
|
|
32
|
+
const hasTroubleJoining = (0, react_1.useMemo)(() => {
|
|
33
|
+
return !joined && duration > waitForCharacterToJoin - 10;
|
|
34
|
+
}, [joined, duration]);
|
|
35
|
+
const joiningCopy = (0, react_1.useMemo)(() => {
|
|
36
|
+
return copy_utils_1.CopyUtils.joiningCopy(locale, name);
|
|
37
|
+
}, [name, locale]);
|
|
38
|
+
const notJoiningCopy = (0, react_1.useMemo)(() => {
|
|
39
|
+
return copy_utils_1.CopyUtils.notJoiningCopy(locale, name);
|
|
40
|
+
}, [name, locale]);
|
|
41
|
+
const endingConversationCopy = (0, react_1.useMemo)(() => {
|
|
42
|
+
return copy_utils_1.CopyUtils.endingConversationCopy(locale, Math.max(waitForCharacterToJoin - duration, 0));
|
|
43
|
+
}, [duration, locale, waitForCharacterToJoin]);
|
|
44
|
+
// Detect if we should leave the conversation because the character is not joining...
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
if (!onShouldLeave)
|
|
47
|
+
return;
|
|
48
|
+
if (!joined && duration > waitForCharacterToJoin) {
|
|
49
|
+
onShouldLeave();
|
|
50
|
+
}
|
|
51
|
+
}, [joined, duration, waitForCharacterToJoin, onShouldLeave]);
|
|
52
|
+
(0, react_1.useEffect)(() => {
|
|
53
|
+
const i = setInterval(() => {
|
|
54
|
+
const elapsedTime = new Date().getTime() - startedAt.getTime();
|
|
55
|
+
const remainingSeconds = Math.round(Math.max(0, maxSeconds * 1000 - elapsedTime) / 1000);
|
|
56
|
+
setRemainingTime(copy_utils_1.CopyUtils.timeLeftCopy(locale, remainingSeconds));
|
|
57
|
+
setDuration((duration) => duration + 1);
|
|
58
|
+
}, 1000);
|
|
59
|
+
return () => clearInterval(i);
|
|
60
|
+
}, [startedAt, maxSeconds]);
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
if (joined) {
|
|
63
|
+
if (!trackRef && !leftTimeout && onShouldLeave) {
|
|
64
|
+
setLeftTimeout(setTimeout(() => {
|
|
65
|
+
onShouldLeave?.();
|
|
66
|
+
}, recoveryTimeInSeconds * 1000));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (trackRef) {
|
|
70
|
+
setJoined(true);
|
|
71
|
+
if (leftTimeout) {
|
|
72
|
+
clearTimeout(leftTimeout);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return () => {
|
|
76
|
+
if (leftTimeout) {
|
|
77
|
+
clearTimeout(leftTimeout);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [joined, trackRef]);
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)('relative w-full h-full overflow-hidden bg-black', className), children: [remainingTime && showTimeLeft && ((0, jsx_runtime_1.jsx)("span", { className: "absolute right-4 top-4 z-20 text-xs text-white rounded-full bg-black/10 py-1 px-2", children: remainingTime })), !joined && !hasTroubleJoining && ((0, jsx_runtime_1.jsx)("span", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-20 text-xs text-white", children: joiningCopy })), !joined && hasTroubleJoining && ((0, jsx_runtime_1.jsxs)("span", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-20 flex flex-col items-center", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-xs text-white", children: notJoiningCopy }), (0, jsx_runtime_1.jsx)("span", { className: "text-xs text-white", children: endingConversationCopy })] })), trackRef && (0, jsx_runtime_1.jsx)(components_react_1.VideoTrack, { trackRef: trackRef, className: "w-full h-full" })] }));
|
|
82
|
+
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { EquosConversationWithCharacter } from '@equos/core';
|
|
2
|
-
|
|
2
|
+
import { EquosLocale } from '../utils/copy.utils';
|
|
3
|
+
export declare function EquosConversationRenderer({ conversation, accessToken, allowMic, allowCamera, allowScreenshare, allowHangUp, className, characterVideoClassName, locale, onHangUp, }: {
|
|
3
4
|
conversation?: EquosConversationWithCharacter | null;
|
|
4
5
|
accessToken?: string | null;
|
|
5
6
|
allowMic?: boolean;
|
|
6
7
|
allowCamera?: boolean;
|
|
7
8
|
allowScreenshare?: boolean;
|
|
8
9
|
className?: string;
|
|
10
|
+
characterVideoClassName?: string;
|
|
9
11
|
allowHangUp?: boolean;
|
|
12
|
+
locale?: EquosLocale;
|
|
10
13
|
onHangUp?: () => void | Promise<void>;
|
|
11
14
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,8 +11,9 @@ const equos_hangup_button_1 = require("./equos-hangup-button");
|
|
|
11
11
|
const react_1 = require("react");
|
|
12
12
|
const livekit_client_1 = require("livekit-client");
|
|
13
13
|
const equos_video_tile_1 = require("./equos-video-tile");
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const equos_character_tile_1 = require("./equos-character-tile");
|
|
15
|
+
const copy_utils_1 = require("../utils/copy.utils");
|
|
16
|
+
function EquosConversationRenderer({ conversation, accessToken, allowMic = true, allowCamera = true, allowScreenshare = false, allowHangUp = true, className, characterVideoClassName, locale = copy_utils_1.EquosLocale.EN, onHangUp, }) {
|
|
16
17
|
const [hangingUp, setHangingUp] = (0, react_1.useState)(false);
|
|
17
18
|
const [_, setMicEnabled] = (0, react_1.useState)(false);
|
|
18
19
|
const [cameraEnabled, setCameraEnabled] = (0, react_1.useState)(false);
|
|
@@ -31,7 +32,7 @@ function EquosConversationRenderer({ conversation, accessToken, allowMic = true,
|
|
|
31
32
|
const [cameraTileDragging, setCameraTileDragging] = (0, react_1.useState)(false);
|
|
32
33
|
const [screenTilePos, setScreenTilePos] = (0, react_1.useState)({
|
|
33
34
|
x: 8,
|
|
34
|
-
y:
|
|
35
|
+
y: 160,
|
|
35
36
|
});
|
|
36
37
|
const [screenTileDragOffset, setScreenTileDragOffset] = (0, react_1.useState)({
|
|
37
38
|
x: 0,
|
|
@@ -105,8 +106,8 @@ function EquosConversationRenderer({ conversation, accessToken, allowMic = true,
|
|
|
105
106
|
return ((0, jsx_runtime_1.jsx)("div", { ref: containerRef, onMouseMove: onMouseMove, onMouseUp: onMouseUp, onMouseLeave: onMouseUp, className: (0, cn_1.cn)('relative w-full h-full', className), children: (0, jsx_runtime_1.jsxs)(components_react_1.LiveKitRoom, { serverUrl: conversation.serverUrl, token: accessToken, audio: allowMic, video: allowCamera, screen: false, className: "w-full h-full", children: [allowCamera && cameraEnabled && ((0, jsx_runtime_1.jsx)("div", { ref: cameraTileRef, onMouseDown: onCameraTileMouseDown, className: (0, cn_1.cn)('absolute z-50 select-none', cameraTileDragging ? 'cursor-grabbing' : 'cursor-grab'), style: {
|
|
106
107
|
top: cameraTilePos.y,
|
|
107
108
|
left: cameraTilePos.x,
|
|
108
|
-
}, children: (0, jsx_runtime_1.jsx)(equos_video_tile_1.EquosVideoTile, { identity: conversation.consumerIdentity, source: livekit_client_1.Track.Source.Camera }) })), allowScreenshare && screenshareEnabled && ((0, jsx_runtime_1.jsx)("div", { ref: screenTileRef, onMouseDown: onScreenTileMouseDown, className: (0, cn_1.cn)('absolute z-50
|
|
109
|
+
}, children: (0, jsx_runtime_1.jsx)(equos_video_tile_1.EquosVideoTile, { identity: conversation.consumerIdentity, source: livekit_client_1.Track.Source.Camera }) })), allowScreenshare && screenshareEnabled && ((0, jsx_runtime_1.jsx)("div", { ref: screenTileRef, onMouseDown: onScreenTileMouseDown, className: (0, cn_1.cn)('absolute z-50', cameraTileDragging ? 'cursor-grabbing' : 'cursor-grab'), style: {
|
|
109
110
|
top: screenTilePos.y,
|
|
110
111
|
left: screenTilePos.x,
|
|
111
|
-
}, children: (0, jsx_runtime_1.jsx)(equos_video_tile_1.EquosVideoTile, { identity: conversation.consumerIdentity, source: livekit_client_1.Track.Source.ScreenShare }) })), (0, jsx_runtime_1.jsx)(
|
|
112
|
+
}, children: (0, jsx_runtime_1.jsx)(equos_video_tile_1.EquosVideoTile, { identity: conversation.consumerIdentity, source: livekit_client_1.Track.Source.ScreenShare }) })), (0, jsx_runtime_1.jsx)(equos_character_tile_1.EquosCharacterTile, { identity: conversation.character.livekitIdentity, name: conversation.character.name, locale: locale, startedAt: conversation.startedAt, maxSeconds: conversation.maxSeconds, recoveryTimeInSeconds: 3, onShouldLeave: handleHangUp, className: characterVideoClassName }), (0, jsx_runtime_1.jsx)(components_react_1.RoomAudioRenderer, {}), (0, jsx_runtime_1.jsxs)("div", { className: "absolute grid grid-cols-3 gap-2 max-w-full bottom-8 left-1/2 -translate-x-1/2", children: [(0, jsx_runtime_1.jsx)("div", { className: "justify-self-end flex items-center", children: allowMic && (0, jsx_runtime_1.jsx)(equos_mic_toggle_1.EquosMicToggle, { onToggle: setMicEnabled }) }), (0, jsx_runtime_1.jsx)("div", { children: allowHangUp && ((0, jsx_runtime_1.jsx)(equos_hangup_button_1.EquosHangupButton, { onHangup: handleHangUp, loading: hangingUp })) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [allowCamera && (0, jsx_runtime_1.jsx)(equos_camera_toggle_1.EquosCameraToggle, { onToggle: setCameraEnabled }), allowScreenshare && ((0, jsx_runtime_1.jsx)(equos_screenshare_toggle_1.EquosScreenshareToggle, { onToggle: setScreenshareEnabled }))] })] })] }) }));
|
|
112
113
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EquosHangupButton = EquosHangupButton;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const lucide_react_1 = require("lucide-react");
|
|
6
|
+
const cn_1 = require("../utils/cn");
|
|
7
|
+
function EquosHangupButton({ className, loading = false, onHangup, }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)('overflow-hidden', 'border shadow-glass backdrop-blur-xs rounded-full cursor-pointer text-white transition-colors p-4 bg-[#FF4133]/80 hover:bg-[#FF4133] border-[#FFCFCC] w-32 flex justify-center items-center', className), type: "button", onClick: onHangup, children: loading ? ((0, jsx_runtime_1.jsx)(lucide_react_1.Loader, { size: 20, className: "animate-spin" })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.PhoneMissed, { size: 20 })) }));
|
|
9
|
+
}
|
|
@@ -8,7 +8,7 @@ const lucide_react_1 = require("lucide-react");
|
|
|
8
8
|
const components_react_1 = require("@livekit/components-react");
|
|
9
9
|
const livekit_client_1 = require("livekit-client");
|
|
10
10
|
function EquosVideoTile({ identity, defaultToLocal = true, className, source = livekit_client_1.Track.Source.Camera, }) {
|
|
11
|
-
const [expanded, setExpanded] = (0, react_1.useState)(
|
|
11
|
+
const [expanded, setExpanded] = (0, react_1.useState)(false);
|
|
12
12
|
const participants = (0, components_react_1.useParticipants)();
|
|
13
13
|
const trackRef = (0, react_1.useMemo)(() => {
|
|
14
14
|
const participant = participants.find((p) => p.identity === identity || (defaultToLocal && p.isLocal));
|
|
@@ -25,5 +25,8 @@ function EquosVideoTile({ identity, defaultToLocal = true, className, source = l
|
|
|
25
25
|
source,
|
|
26
26
|
};
|
|
27
27
|
}, [identity, source, participants]);
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)('relative border border-white/60 shadow-xl rounded-2xl bg-black aspect-video transition-all max-w-full overflow-hidden', expanded ? 'w-96' : 'w-64', className), children: [(0, jsx_runtime_1.jsx)("button", { className: "absolute top-
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)('relative border border-white/60 shadow-xl rounded-2xl bg-black aspect-video transition-all max-w-full overflow-hidden', expanded ? 'w-96' : 'w-64', className), children: [(0, jsx_runtime_1.jsx)("button", { className: "absolute top-2 right-2 text-white cursor-pointer p-2 z-10 hover:bg-black/10 rounded-full transition-colors", onClick: (e) => {
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
setExpanded(!expanded);
|
|
31
|
+
}, children: expanded ? (0, jsx_runtime_1.jsx)(lucide_react_1.Minimize2, { size: 12 }) : (0, jsx_runtime_1.jsx)(lucide_react_1.Maximize2, { size: 12 }) }), trackRef && (0, jsx_runtime_1.jsx)(components_react_1.VideoTrack, { trackRef: trackRef, className: "w-full h-full" })] }));
|
|
29
32
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './equos-logo';
|
|
2
|
+
export * from './equos-mic-toggle';
|
|
3
|
+
export * from './equos-camera-toggle';
|
|
4
|
+
export * from './equos-screenshare-toggle';
|
|
5
|
+
export * from './equos-hangup-button';
|
|
6
|
+
export * from './equos-video-tile';
|
|
7
|
+
export * from './equos-character-tile';
|
|
8
|
+
export * from './equos-conversation-renderer';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./equos-logo"), exports);
|
|
18
|
+
__exportStar(require("./equos-mic-toggle"), exports);
|
|
19
|
+
__exportStar(require("./equos-camera-toggle"), exports);
|
|
20
|
+
__exportStar(require("./equos-screenshare-toggle"), exports);
|
|
21
|
+
__exportStar(require("./equos-hangup-button"), exports);
|
|
22
|
+
__exportStar(require("./equos-video-tile"), exports);
|
|
23
|
+
__exportStar(require("./equos-character-tile"), exports);
|
|
24
|
+
__exportStar(require("./equos-conversation-renderer"), exports);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./client"), exports);
|