@talkif/webrtc-react 0.1.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/LICENSE +21 -0
- package/dist/index.cjs +132 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Talkif
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
useTalkifCall: () => useTalkifCall
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/use-talkif-call.ts
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_webrtc = require("@talkif/webrtc");
|
|
30
|
+
function useTalkifCall(options) {
|
|
31
|
+
const { config, onAppMessage, onCallEvent, onTranscript, onTtsWord, onTtsChunk, onEnded, onError } = options;
|
|
32
|
+
const callRef = (0, import_react.useRef)(null);
|
|
33
|
+
const [state, setState] = (0, import_react.useState)("idle");
|
|
34
|
+
const [callId, setCallId] = (0, import_react.useState)(null);
|
|
35
|
+
const [botId, setBotId] = (0, import_react.useState)(null);
|
|
36
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
37
|
+
const [durationSecs, setDurationSecs] = (0, import_react.useState)(0);
|
|
38
|
+
const [muted, setMuted] = (0, import_react.useState)(false);
|
|
39
|
+
const callbacksRef = (0, import_react.useRef)({
|
|
40
|
+
onAppMessage,
|
|
41
|
+
onCallEvent,
|
|
42
|
+
onTranscript,
|
|
43
|
+
onTtsWord,
|
|
44
|
+
onTtsChunk,
|
|
45
|
+
onEnded,
|
|
46
|
+
onError
|
|
47
|
+
});
|
|
48
|
+
callbacksRef.current = {
|
|
49
|
+
onAppMessage,
|
|
50
|
+
onCallEvent,
|
|
51
|
+
onTranscript,
|
|
52
|
+
onTtsWord,
|
|
53
|
+
onTtsChunk,
|
|
54
|
+
onEnded,
|
|
55
|
+
onError
|
|
56
|
+
};
|
|
57
|
+
const identity = (0, import_webrtc.isPublicConfig)(config) ? [config.baseUrl, config.publishableKey, config.turnstileToken, config.fetch] : [config.baseUrl, config.accountId, config.auth, config.fetch];
|
|
58
|
+
const stableConfig = (0, import_react.useMemo)(
|
|
59
|
+
() => config,
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
identity
|
|
62
|
+
);
|
|
63
|
+
(0, import_react.useEffect)(() => {
|
|
64
|
+
return () => {
|
|
65
|
+
callRef.current?.dispose();
|
|
66
|
+
callRef.current = null;
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
const start = (0, import_react.useCallback)(
|
|
70
|
+
async (startOptions) => {
|
|
71
|
+
callRef.current?.dispose();
|
|
72
|
+
const call = new import_webrtc.TalkifCall(stableConfig);
|
|
73
|
+
callRef.current = call;
|
|
74
|
+
setError(null);
|
|
75
|
+
setCallId(null);
|
|
76
|
+
setBotId(null);
|
|
77
|
+
setDurationSecs(0);
|
|
78
|
+
setMuted(false);
|
|
79
|
+
call.on("statechange", ({ state: next }) => setState(next));
|
|
80
|
+
call.on("connected", ({ callId: id, botId: bot }) => {
|
|
81
|
+
setCallId(id);
|
|
82
|
+
setBotId(bot);
|
|
83
|
+
});
|
|
84
|
+
call.on("tick", ({ durationSecs: secs }) => setDurationSecs(secs));
|
|
85
|
+
call.on("mutechange", ({ muted: m }) => setMuted(m));
|
|
86
|
+
call.on("appmessage", ({ message }) => callbacksRef.current.onAppMessage?.(message));
|
|
87
|
+
call.on("callevent", ({ event }) => callbacksRef.current.onCallEvent?.(event));
|
|
88
|
+
call.on(
|
|
89
|
+
"transcript",
|
|
90
|
+
({ role, content }) => callbacksRef.current.onTranscript?.({ role, content })
|
|
91
|
+
);
|
|
92
|
+
call.on("ttsword", (payload) => callbacksRef.current.onTtsWord?.(payload));
|
|
93
|
+
call.on("ttschunk", (payload) => callbacksRef.current.onTtsChunk?.(payload));
|
|
94
|
+
call.on("ended", ({ reason }) => callbacksRef.current.onEnded?.(reason));
|
|
95
|
+
call.on("error", ({ error: err }) => {
|
|
96
|
+
setError(err);
|
|
97
|
+
callbacksRef.current.onError?.(err);
|
|
98
|
+
});
|
|
99
|
+
await call.start(startOptions);
|
|
100
|
+
},
|
|
101
|
+
[stableConfig]
|
|
102
|
+
);
|
|
103
|
+
const hangup = (0, import_react.useCallback)(() => {
|
|
104
|
+
callRef.current?.hangup();
|
|
105
|
+
}, []);
|
|
106
|
+
const toggleMute = (0, import_react.useCallback)(() => {
|
|
107
|
+
const call = callRef.current;
|
|
108
|
+
if (!call) return;
|
|
109
|
+
call.setMuted(!call.muted);
|
|
110
|
+
}, []);
|
|
111
|
+
const sendAppMessage = (0, import_react.useCallback)((message) => {
|
|
112
|
+
return callRef.current?.sendAppMessage(message) ?? false;
|
|
113
|
+
}, []);
|
|
114
|
+
return {
|
|
115
|
+
state,
|
|
116
|
+
callId,
|
|
117
|
+
botId,
|
|
118
|
+
error,
|
|
119
|
+
durationSecs,
|
|
120
|
+
muted,
|
|
121
|
+
call: callRef.current,
|
|
122
|
+
start,
|
|
123
|
+
hangup,
|
|
124
|
+
toggleMute,
|
|
125
|
+
sendAppMessage
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
useTalkifCall
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/use-talkif-call.ts"],"sourcesContent":["export { useTalkifCall } from './use-talkif-call.js';\nexport type { UseTalkifCallOptions, UseTalkifCallResult } from './use-talkif-call.js';\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { isPublicConfig, TalkifCall } from '@talkif/webrtc';\nimport type {\n\tAppMessage,\n\tCallEndReason,\n\tCallEventEnvelope,\n\tCallState,\n\tStartCallOptions,\n\tTalkifCallError,\n\tTalkifConfig,\n\tTtsChunkEvent,\n\tTtsWordEvent,\n} from '@talkif/webrtc';\n\nexport interface UseTalkifCallOptions {\n\t/**\n\t * Authenticated (`accountId` + `auth`) or public (`publishableKey`)\n\t * configuration — public mode also streams realtime call events.\n\t */\n\tconfig: TalkifConfig;\n\t/** Fired for every JSON app message from the bot (e.g. transcripts). */\n\tonAppMessage?: (message: AppMessage) => void;\n\t/** Public mode: every realtime event for this call (transcript, status…). */\n\tonCallEvent?: (event: CallEventEnvelope) => void;\n\t/** Public mode: final transcript lines. */\n\tonTranscript?: (payload: { role: string; content: string }) => void;\n\t/** Public mode: word-level TTS timing (karaoke). May be dropped under backpressure. */\n\tonTtsWord?: (payload: TtsWordEvent) => void;\n\t/**\n\t * Public mode: sentence-level chunk of the agent's reply, ahead of audio\n\t * playback (chat-style streaming). Reconcile with the final transcript.\n\t */\n\tonTtsChunk?: (payload: TtsChunkEvent) => void;\n\tonEnded?: (reason: CallEndReason) => void;\n\tonError?: (error: TalkifCallError) => void;\n}\n\nexport interface UseTalkifCallResult {\n\tstate: CallState;\n\tcallId: string | null;\n\tbotId: string | null;\n\terror: TalkifCallError | null;\n\tdurationSecs: number;\n\tmuted: boolean;\n\t/** Live call handle for advanced use (sendAppMessage, confirmPipelineHealthy…). */\n\tcall: TalkifCall | null;\n\tstart: (options: StartCallOptions) => Promise<void>;\n\thangup: () => void;\n\ttoggleMute: () => void;\n\tsendAppMessage: (message: AppMessage) => boolean;\n}\n\n/**\n * Headless React binding for TalkifCall. One active call at a time; starting\n * a new call disposes the previous instance. All teardown (mic, peer\n * connection, timers) happens automatically on unmount.\n */\nexport function useTalkifCall(options: UseTalkifCallOptions): UseTalkifCallResult {\n\tconst { config, onAppMessage, onCallEvent, onTranscript, onTtsWord, onTtsChunk, onEnded, onError } =\n\t\toptions;\n\n\tconst callRef = useRef<TalkifCall | null>(null);\n\tconst [state, setState] = useState<CallState>('idle');\n\tconst [callId, setCallId] = useState<string | null>(null);\n\tconst [botId, setBotId] = useState<string | null>(null);\n\tconst [error, setError] = useState<TalkifCallError | null>(null);\n\tconst [durationSecs, setDurationSecs] = useState(0);\n\tconst [muted, setMuted] = useState(false);\n\n\t// Keep callbacks in refs so subscriptions survive re-renders without\n\t// re-wiring the emitter.\n\tconst callbacksRef = useRef({\n\t\tonAppMessage,\n\t\tonCallEvent,\n\t\tonTranscript,\n\t\tonTtsWord,\n\t\tonTtsChunk,\n\t\tonEnded,\n\t\tonError,\n\t});\n\tcallbacksRef.current = {\n\t\tonAppMessage,\n\t\tonCallEvent,\n\t\tonTranscript,\n\t\tonTtsWord,\n\t\tonTtsChunk,\n\t\tonEnded,\n\t\tonError,\n\t};\n\n\t// The config object identity is the session identity — memoize on fields.\n\tconst identity = isPublicConfig(config)\n\t\t? [config.baseUrl, config.publishableKey, config.turnstileToken, config.fetch]\n\t\t: [config.baseUrl, config.accountId, config.auth, config.fetch];\n\tconst stableConfig = useMemo(\n\t\t() => config,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tidentity\n\t);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tcallRef.current?.dispose();\n\t\t\tcallRef.current = null;\n\t\t};\n\t}, []);\n\n\tconst start = useCallback(\n\t\tasync (startOptions: StartCallOptions) => {\n\t\t\t// Single-use instances: replace any prior call.\n\t\t\tcallRef.current?.dispose();\n\n\t\t\tconst call = new TalkifCall(stableConfig);\n\t\t\tcallRef.current = call;\n\t\t\tsetError(null);\n\t\t\tsetCallId(null);\n\t\t\tsetBotId(null);\n\t\t\tsetDurationSecs(0);\n\t\t\tsetMuted(false);\n\n\t\t\tcall.on('statechange', ({ state: next }) => setState(next));\n\t\t\tcall.on('connected', ({ callId: id, botId: bot }) => {\n\t\t\t\tsetCallId(id);\n\t\t\t\tsetBotId(bot);\n\t\t\t});\n\t\t\tcall.on('tick', ({ durationSecs: secs }) => setDurationSecs(secs));\n\t\t\tcall.on('mutechange', ({ muted: m }) => setMuted(m));\n\t\t\tcall.on('appmessage', ({ message }) => callbacksRef.current.onAppMessage?.(message));\n\t\t\tcall.on('callevent', ({ event }) => callbacksRef.current.onCallEvent?.(event));\n\t\t\tcall.on('transcript', ({ role, content }) =>\n\t\t\t\tcallbacksRef.current.onTranscript?.({ role, content })\n\t\t\t);\n\t\t\tcall.on('ttsword', (payload) => callbacksRef.current.onTtsWord?.(payload));\n\t\t\tcall.on('ttschunk', (payload) => callbacksRef.current.onTtsChunk?.(payload));\n\t\t\tcall.on('ended', ({ reason }) => callbacksRef.current.onEnded?.(reason));\n\t\t\tcall.on('error', ({ error: err }) => {\n\t\t\t\tsetError(err);\n\t\t\t\tcallbacksRef.current.onError?.(err);\n\t\t\t});\n\n\t\t\tawait call.start(startOptions);\n\t\t},\n\t\t[stableConfig]\n\t);\n\n\tconst hangup = useCallback(() => {\n\t\tcallRef.current?.hangup();\n\t}, []);\n\n\tconst toggleMute = useCallback(() => {\n\t\tconst call = callRef.current;\n\t\tif (!call) return;\n\t\tcall.setMuted(!call.muted);\n\t}, []);\n\n\tconst sendAppMessage = useCallback((message: AppMessage): boolean => {\n\t\treturn callRef.current?.sendAppMessage(message) ?? false;\n\t}, []);\n\n\treturn {\n\t\tstate,\n\t\tcallId,\n\t\tbotId,\n\t\terror,\n\t\tdurationSecs,\n\t\tmuted,\n\t\tcall: callRef.current,\n\t\tstart,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C,YAAQ,SAAS,OAAO;AAAA,EACzB,GAAG,CAAC,CAAC;AAEL,QAAM,iBAAa,0BAAY,MAAM;AACpC,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,KAAM;AACX,SAAK,SAAS,CAAC,KAAK,KAAK;AAAA,EAC1B,GAAG,CAAC,CAAC;AAEL,QAAM,qBAAiB,0BAAY,CAAC,YAAiC;AACpE,WAAO,QAAQ,SAAS,eAAe,OAAO,KAAK;AAAA,EACpD,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,QAAQ;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TalkifConfig, AppMessage, CallEventEnvelope, TtsWordEvent, TtsChunkEvent, CallEndReason, TalkifCallError, CallState, TalkifCall, StartCallOptions } from '@talkif/webrtc';
|
|
2
|
+
|
|
3
|
+
interface UseTalkifCallOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Authenticated (`accountId` + `auth`) or public (`publishableKey`)
|
|
6
|
+
* configuration — public mode also streams realtime call events.
|
|
7
|
+
*/
|
|
8
|
+
config: TalkifConfig;
|
|
9
|
+
/** Fired for every JSON app message from the bot (e.g. transcripts). */
|
|
10
|
+
onAppMessage?: (message: AppMessage) => void;
|
|
11
|
+
/** Public mode: every realtime event for this call (transcript, status…). */
|
|
12
|
+
onCallEvent?: (event: CallEventEnvelope) => void;
|
|
13
|
+
/** Public mode: final transcript lines. */
|
|
14
|
+
onTranscript?: (payload: {
|
|
15
|
+
role: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
/** Public mode: word-level TTS timing (karaoke). May be dropped under backpressure. */
|
|
19
|
+
onTtsWord?: (payload: TtsWordEvent) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Public mode: sentence-level chunk of the agent's reply, ahead of audio
|
|
22
|
+
* playback (chat-style streaming). Reconcile with the final transcript.
|
|
23
|
+
*/
|
|
24
|
+
onTtsChunk?: (payload: TtsChunkEvent) => void;
|
|
25
|
+
onEnded?: (reason: CallEndReason) => void;
|
|
26
|
+
onError?: (error: TalkifCallError) => void;
|
|
27
|
+
}
|
|
28
|
+
interface UseTalkifCallResult {
|
|
29
|
+
state: CallState;
|
|
30
|
+
callId: string | null;
|
|
31
|
+
botId: string | null;
|
|
32
|
+
error: TalkifCallError | null;
|
|
33
|
+
durationSecs: number;
|
|
34
|
+
muted: boolean;
|
|
35
|
+
/** Live call handle for advanced use (sendAppMessage, confirmPipelineHealthy…). */
|
|
36
|
+
call: TalkifCall | null;
|
|
37
|
+
start: (options: StartCallOptions) => Promise<void>;
|
|
38
|
+
hangup: () => void;
|
|
39
|
+
toggleMute: () => void;
|
|
40
|
+
sendAppMessage: (message: AppMessage) => boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Headless React binding for TalkifCall. One active call at a time; starting
|
|
44
|
+
* a new call disposes the previous instance. All teardown (mic, peer
|
|
45
|
+
* connection, timers) happens automatically on unmount.
|
|
46
|
+
*/
|
|
47
|
+
declare function useTalkifCall(options: UseTalkifCallOptions): UseTalkifCallResult;
|
|
48
|
+
|
|
49
|
+
export { type UseTalkifCallOptions, type UseTalkifCallResult, useTalkifCall };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TalkifConfig, AppMessage, CallEventEnvelope, TtsWordEvent, TtsChunkEvent, CallEndReason, TalkifCallError, CallState, TalkifCall, StartCallOptions } from '@talkif/webrtc';
|
|
2
|
+
|
|
3
|
+
interface UseTalkifCallOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Authenticated (`accountId` + `auth`) or public (`publishableKey`)
|
|
6
|
+
* configuration — public mode also streams realtime call events.
|
|
7
|
+
*/
|
|
8
|
+
config: TalkifConfig;
|
|
9
|
+
/** Fired for every JSON app message from the bot (e.g. transcripts). */
|
|
10
|
+
onAppMessage?: (message: AppMessage) => void;
|
|
11
|
+
/** Public mode: every realtime event for this call (transcript, status…). */
|
|
12
|
+
onCallEvent?: (event: CallEventEnvelope) => void;
|
|
13
|
+
/** Public mode: final transcript lines. */
|
|
14
|
+
onTranscript?: (payload: {
|
|
15
|
+
role: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
/** Public mode: word-level TTS timing (karaoke). May be dropped under backpressure. */
|
|
19
|
+
onTtsWord?: (payload: TtsWordEvent) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Public mode: sentence-level chunk of the agent's reply, ahead of audio
|
|
22
|
+
* playback (chat-style streaming). Reconcile with the final transcript.
|
|
23
|
+
*/
|
|
24
|
+
onTtsChunk?: (payload: TtsChunkEvent) => void;
|
|
25
|
+
onEnded?: (reason: CallEndReason) => void;
|
|
26
|
+
onError?: (error: TalkifCallError) => void;
|
|
27
|
+
}
|
|
28
|
+
interface UseTalkifCallResult {
|
|
29
|
+
state: CallState;
|
|
30
|
+
callId: string | null;
|
|
31
|
+
botId: string | null;
|
|
32
|
+
error: TalkifCallError | null;
|
|
33
|
+
durationSecs: number;
|
|
34
|
+
muted: boolean;
|
|
35
|
+
/** Live call handle for advanced use (sendAppMessage, confirmPipelineHealthy…). */
|
|
36
|
+
call: TalkifCall | null;
|
|
37
|
+
start: (options: StartCallOptions) => Promise<void>;
|
|
38
|
+
hangup: () => void;
|
|
39
|
+
toggleMute: () => void;
|
|
40
|
+
sendAppMessage: (message: AppMessage) => boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Headless React binding for TalkifCall. One active call at a time; starting
|
|
44
|
+
* a new call disposes the previous instance. All teardown (mic, peer
|
|
45
|
+
* connection, timers) happens automatically on unmount.
|
|
46
|
+
*/
|
|
47
|
+
declare function useTalkifCall(options: UseTalkifCallOptions): UseTalkifCallResult;
|
|
48
|
+
|
|
49
|
+
export { type UseTalkifCallOptions, type UseTalkifCallResult, useTalkifCall };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/use-talkif-call.ts
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { isPublicConfig, TalkifCall } from "@talkif/webrtc";
|
|
4
|
+
function useTalkifCall(options) {
|
|
5
|
+
const { config, onAppMessage, onCallEvent, onTranscript, onTtsWord, onTtsChunk, onEnded, onError } = options;
|
|
6
|
+
const callRef = useRef(null);
|
|
7
|
+
const [state, setState] = useState("idle");
|
|
8
|
+
const [callId, setCallId] = useState(null);
|
|
9
|
+
const [botId, setBotId] = useState(null);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
const [durationSecs, setDurationSecs] = useState(0);
|
|
12
|
+
const [muted, setMuted] = useState(false);
|
|
13
|
+
const callbacksRef = useRef({
|
|
14
|
+
onAppMessage,
|
|
15
|
+
onCallEvent,
|
|
16
|
+
onTranscript,
|
|
17
|
+
onTtsWord,
|
|
18
|
+
onTtsChunk,
|
|
19
|
+
onEnded,
|
|
20
|
+
onError
|
|
21
|
+
});
|
|
22
|
+
callbacksRef.current = {
|
|
23
|
+
onAppMessage,
|
|
24
|
+
onCallEvent,
|
|
25
|
+
onTranscript,
|
|
26
|
+
onTtsWord,
|
|
27
|
+
onTtsChunk,
|
|
28
|
+
onEnded,
|
|
29
|
+
onError
|
|
30
|
+
};
|
|
31
|
+
const identity = isPublicConfig(config) ? [config.baseUrl, config.publishableKey, config.turnstileToken, config.fetch] : [config.baseUrl, config.accountId, config.auth, config.fetch];
|
|
32
|
+
const stableConfig = useMemo(
|
|
33
|
+
() => config,
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
identity
|
|
36
|
+
);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
return () => {
|
|
39
|
+
callRef.current?.dispose();
|
|
40
|
+
callRef.current = null;
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
const start = useCallback(
|
|
44
|
+
async (startOptions) => {
|
|
45
|
+
callRef.current?.dispose();
|
|
46
|
+
const call = new TalkifCall(stableConfig);
|
|
47
|
+
callRef.current = call;
|
|
48
|
+
setError(null);
|
|
49
|
+
setCallId(null);
|
|
50
|
+
setBotId(null);
|
|
51
|
+
setDurationSecs(0);
|
|
52
|
+
setMuted(false);
|
|
53
|
+
call.on("statechange", ({ state: next }) => setState(next));
|
|
54
|
+
call.on("connected", ({ callId: id, botId: bot }) => {
|
|
55
|
+
setCallId(id);
|
|
56
|
+
setBotId(bot);
|
|
57
|
+
});
|
|
58
|
+
call.on("tick", ({ durationSecs: secs }) => setDurationSecs(secs));
|
|
59
|
+
call.on("mutechange", ({ muted: m }) => setMuted(m));
|
|
60
|
+
call.on("appmessage", ({ message }) => callbacksRef.current.onAppMessage?.(message));
|
|
61
|
+
call.on("callevent", ({ event }) => callbacksRef.current.onCallEvent?.(event));
|
|
62
|
+
call.on(
|
|
63
|
+
"transcript",
|
|
64
|
+
({ role, content }) => callbacksRef.current.onTranscript?.({ role, content })
|
|
65
|
+
);
|
|
66
|
+
call.on("ttsword", (payload) => callbacksRef.current.onTtsWord?.(payload));
|
|
67
|
+
call.on("ttschunk", (payload) => callbacksRef.current.onTtsChunk?.(payload));
|
|
68
|
+
call.on("ended", ({ reason }) => callbacksRef.current.onEnded?.(reason));
|
|
69
|
+
call.on("error", ({ error: err }) => {
|
|
70
|
+
setError(err);
|
|
71
|
+
callbacksRef.current.onError?.(err);
|
|
72
|
+
});
|
|
73
|
+
await call.start(startOptions);
|
|
74
|
+
},
|
|
75
|
+
[stableConfig]
|
|
76
|
+
);
|
|
77
|
+
const hangup = useCallback(() => {
|
|
78
|
+
callRef.current?.hangup();
|
|
79
|
+
}, []);
|
|
80
|
+
const toggleMute = useCallback(() => {
|
|
81
|
+
const call = callRef.current;
|
|
82
|
+
if (!call) return;
|
|
83
|
+
call.setMuted(!call.muted);
|
|
84
|
+
}, []);
|
|
85
|
+
const sendAppMessage = useCallback((message) => {
|
|
86
|
+
return callRef.current?.sendAppMessage(message) ?? false;
|
|
87
|
+
}, []);
|
|
88
|
+
return {
|
|
89
|
+
state,
|
|
90
|
+
callId,
|
|
91
|
+
botId,
|
|
92
|
+
error,
|
|
93
|
+
durationSecs,
|
|
94
|
+
muted,
|
|
95
|
+
call: callRef.current,
|
|
96
|
+
start,
|
|
97
|
+
hangup,
|
|
98
|
+
toggleMute,
|
|
99
|
+
sendAppMessage
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
useTalkifCall
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-talkif-call.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { isPublicConfig, TalkifCall } from '@talkif/webrtc';\nimport type {\n\tAppMessage,\n\tCallEndReason,\n\tCallEventEnvelope,\n\tCallState,\n\tStartCallOptions,\n\tTalkifCallError,\n\tTalkifConfig,\n\tTtsChunkEvent,\n\tTtsWordEvent,\n} from '@talkif/webrtc';\n\nexport interface UseTalkifCallOptions {\n\t/**\n\t * Authenticated (`accountId` + `auth`) or public (`publishableKey`)\n\t * configuration — public mode also streams realtime call events.\n\t */\n\tconfig: TalkifConfig;\n\t/** Fired for every JSON app message from the bot (e.g. transcripts). */\n\tonAppMessage?: (message: AppMessage) => void;\n\t/** Public mode: every realtime event for this call (transcript, status…). */\n\tonCallEvent?: (event: CallEventEnvelope) => void;\n\t/** Public mode: final transcript lines. */\n\tonTranscript?: (payload: { role: string; content: string }) => void;\n\t/** Public mode: word-level TTS timing (karaoke). May be dropped under backpressure. */\n\tonTtsWord?: (payload: TtsWordEvent) => void;\n\t/**\n\t * Public mode: sentence-level chunk of the agent's reply, ahead of audio\n\t * playback (chat-style streaming). Reconcile with the final transcript.\n\t */\n\tonTtsChunk?: (payload: TtsChunkEvent) => void;\n\tonEnded?: (reason: CallEndReason) => void;\n\tonError?: (error: TalkifCallError) => void;\n}\n\nexport interface UseTalkifCallResult {\n\tstate: CallState;\n\tcallId: string | null;\n\tbotId: string | null;\n\terror: TalkifCallError | null;\n\tdurationSecs: number;\n\tmuted: boolean;\n\t/** Live call handle for advanced use (sendAppMessage, confirmPipelineHealthy…). */\n\tcall: TalkifCall | null;\n\tstart: (options: StartCallOptions) => Promise<void>;\n\thangup: () => void;\n\ttoggleMute: () => void;\n\tsendAppMessage: (message: AppMessage) => boolean;\n}\n\n/**\n * Headless React binding for TalkifCall. One active call at a time; starting\n * a new call disposes the previous instance. All teardown (mic, peer\n * connection, timers) happens automatically on unmount.\n */\nexport function useTalkifCall(options: UseTalkifCallOptions): UseTalkifCallResult {\n\tconst { config, onAppMessage, onCallEvent, onTranscript, onTtsWord, onTtsChunk, onEnded, onError } =\n\t\toptions;\n\n\tconst callRef = useRef<TalkifCall | null>(null);\n\tconst [state, setState] = useState<CallState>('idle');\n\tconst [callId, setCallId] = useState<string | null>(null);\n\tconst [botId, setBotId] = useState<string | null>(null);\n\tconst [error, setError] = useState<TalkifCallError | null>(null);\n\tconst [durationSecs, setDurationSecs] = useState(0);\n\tconst [muted, setMuted] = useState(false);\n\n\t// Keep callbacks in refs so subscriptions survive re-renders without\n\t// re-wiring the emitter.\n\tconst callbacksRef = useRef({\n\t\tonAppMessage,\n\t\tonCallEvent,\n\t\tonTranscript,\n\t\tonTtsWord,\n\t\tonTtsChunk,\n\t\tonEnded,\n\t\tonError,\n\t});\n\tcallbacksRef.current = {\n\t\tonAppMessage,\n\t\tonCallEvent,\n\t\tonTranscript,\n\t\tonTtsWord,\n\t\tonTtsChunk,\n\t\tonEnded,\n\t\tonError,\n\t};\n\n\t// The config object identity is the session identity — memoize on fields.\n\tconst identity = isPublicConfig(config)\n\t\t? [config.baseUrl, config.publishableKey, config.turnstileToken, config.fetch]\n\t\t: [config.baseUrl, config.accountId, config.auth, config.fetch];\n\tconst stableConfig = useMemo(\n\t\t() => config,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tidentity\n\t);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tcallRef.current?.dispose();\n\t\t\tcallRef.current = null;\n\t\t};\n\t}, []);\n\n\tconst start = useCallback(\n\t\tasync (startOptions: StartCallOptions) => {\n\t\t\t// Single-use instances: replace any prior call.\n\t\t\tcallRef.current?.dispose();\n\n\t\t\tconst call = new TalkifCall(stableConfig);\n\t\t\tcallRef.current = call;\n\t\t\tsetError(null);\n\t\t\tsetCallId(null);\n\t\t\tsetBotId(null);\n\t\t\tsetDurationSecs(0);\n\t\t\tsetMuted(false);\n\n\t\t\tcall.on('statechange', ({ state: next }) => setState(next));\n\t\t\tcall.on('connected', ({ callId: id, botId: bot }) => {\n\t\t\t\tsetCallId(id);\n\t\t\t\tsetBotId(bot);\n\t\t\t});\n\t\t\tcall.on('tick', ({ durationSecs: secs }) => setDurationSecs(secs));\n\t\t\tcall.on('mutechange', ({ muted: m }) => setMuted(m));\n\t\t\tcall.on('appmessage', ({ message }) => callbacksRef.current.onAppMessage?.(message));\n\t\t\tcall.on('callevent', ({ event }) => callbacksRef.current.onCallEvent?.(event));\n\t\t\tcall.on('transcript', ({ role, content }) =>\n\t\t\t\tcallbacksRef.current.onTranscript?.({ role, content })\n\t\t\t);\n\t\t\tcall.on('ttsword', (payload) => callbacksRef.current.onTtsWord?.(payload));\n\t\t\tcall.on('ttschunk', (payload) => callbacksRef.current.onTtsChunk?.(payload));\n\t\t\tcall.on('ended', ({ reason }) => callbacksRef.current.onEnded?.(reason));\n\t\t\tcall.on('error', ({ error: err }) => {\n\t\t\t\tsetError(err);\n\t\t\t\tcallbacksRef.current.onError?.(err);\n\t\t\t});\n\n\t\t\tawait call.start(startOptions);\n\t\t},\n\t\t[stableConfig]\n\t);\n\n\tconst hangup = useCallback(() => {\n\t\tcallRef.current?.hangup();\n\t}, []);\n\n\tconst toggleMute = useCallback(() => {\n\t\tconst call = callRef.current;\n\t\tif (!call) return;\n\t\tcall.setMuted(!call.muted);\n\t}, []);\n\n\tconst sendAppMessage = useCallback((message: AppMessage): boolean => {\n\t\treturn callRef.current?.sendAppMessage(message) ?? false;\n\t}, []);\n\n\treturn {\n\t\tstate,\n\t\tcallId,\n\t\tbotId,\n\t\terror,\n\t\tdurationSecs,\n\t\tmuted,\n\t\tcall: callRef.current,\n\t\tstart,\n\t\thangup,\n\t\ttoggleMute,\n\t\tsendAppMessage,\n\t};\n}\n"],"mappings":";AAAA,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAClE,SAAS,gBAAgB,kBAAkB;AAwDpC,SAAS,cAAc,SAAoD;AACjF,QAAM,EAAE,QAAQ,cAAc,aAAa,cAAc,WAAW,YAAY,SAAS,QAAQ,IAChG;AAED,QAAM,UAAU,OAA0B,IAAI;AAC9C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB,MAAM;AACpD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAwB,IAAI;AACxD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AACtD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAiC,IAAI;AAC/D,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,CAAC;AAClD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,KAAK;AAIxC,QAAM,eAAe,OAAO;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AACD,eAAa,UAAU;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAGA,QAAM,WAAW,eAAe,MAAM,IACnC,CAAC,OAAO,SAAS,OAAO,gBAAgB,OAAO,gBAAgB,OAAO,KAAK,IAC3E,CAAC,OAAO,SAAS,OAAO,WAAW,OAAO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AAM,aAAa,QAAQ,UAAU,MAAM,CAAC;AACvE,WAAK,GAAG,SAAS,CAAC,EAAE,OAAO,IAAI,MAAM;AACpC,iBAAS,GAAG;AACZ,qBAAa,QAAQ,UAAU,GAAG;AAAA,MACnC,CAAC;AAED,YAAM,KAAK,MAAM,YAAY;AAAA,IAC9B;AAAA,IACA,CAAC,YAAY;AAAA,EACd;AAEA,QAAM,SAAS,YAAY,MAAM;AAChC,YAAQ,SAAS,OAAO;AAAA,EACzB,GAAG,CAAC,CAAC;AAEL,QAAM,aAAa,YAAY,MAAM;AACpC,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,KAAM;AACX,SAAK,SAAS,CAAC,KAAK,KAAK;AAAA,EAC1B,GAAG,CAAC,CAAC;AAEL,QAAM,iBAAiB,YAAY,CAAC,YAAiC;AACpE,WAAO,QAAQ,SAAS,eAAe,OAAO,KAAK;AAAA,EACpD,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,QAAQ;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@talkif/webrtc-react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React bindings for @talkif/webrtc — headless hook for Talkif voice sessions",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Talkif-ai/webrtc-js.git",
|
|
9
|
+
"directory": "packages/react"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": ">=18",
|
|
28
|
+
"@talkif/webrtc": "^0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/react": "^19.1.0",
|
|
32
|
+
"react": "^19.1.0",
|
|
33
|
+
"tsup": "^8.4.0",
|
|
34
|
+
"typescript": "^5.8.3",
|
|
35
|
+
"@talkif/webrtc": "0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --sourcemap --clean --external react,@talkif/webrtc",
|
|
39
|
+
"dev": "tsup src/index.ts --format esm --dts --watch --external react,@talkif/webrtc",
|
|
40
|
+
"type-check": "tsc --noEmit"
|
|
41
|
+
}
|
|
42
|
+
}
|