scribe-widget 1.0.7 → 1.0.9
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/scribe-widget.es.js +514 -509
- package/dist/scribe-widget.umd.js +15 -15
- package/package.json +1 -1
- package/src/App.tsx +6 -6
- package/src/components/ConfigState.tsx +10 -10
- package/src/hooks/useScribeSession.ts +14 -10
- package/src/index.tsx +3 -1
- package/src/types.ts +10 -3
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -17,8 +17,8 @@ interface AppProps {
|
|
|
17
17
|
|
|
18
18
|
export function App({ config: initialConfig, onClose }: AppProps) {
|
|
19
19
|
const [isMinimized, setIsMinimized] = useState(false);
|
|
20
|
-
const [credentials, setCredentials] = useState<{
|
|
21
|
-
initialConfig.baseUrl ? {
|
|
20
|
+
const [credentials, setCredentials] = useState<{ accessToken?: string; baseUrl: string } | null>(
|
|
21
|
+
initialConfig.baseUrl ? { accessToken: initialConfig.accessToken, baseUrl: initialConfig.baseUrl } : null
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
// Merge initial config with user-provided credentials
|
|
@@ -28,7 +28,7 @@ export function App({ config: initialConfig, onClose }: AppProps) {
|
|
|
28
28
|
}
|
|
29
29
|
return {
|
|
30
30
|
...initialConfig,
|
|
31
|
-
|
|
31
|
+
accessToken: credentials.accessToken,
|
|
32
32
|
baseUrl: credentials.baseUrl,
|
|
33
33
|
};
|
|
34
34
|
}, [initialConfig, credentials]);
|
|
@@ -51,8 +51,8 @@ export function App({ config: initialConfig, onClose }: AppProps) {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const handleConfigSubmit = (
|
|
55
|
-
setCredentials({
|
|
54
|
+
const handleConfigSubmit = (accessToken: string, baseUrl: string) => {
|
|
55
|
+
setCredentials({ accessToken, baseUrl });
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
const renderContent = () => {
|
|
@@ -61,7 +61,7 @@ export function App({ config: initialConfig, onClose }: AppProps) {
|
|
|
61
61
|
return (
|
|
62
62
|
<ConfigState
|
|
63
63
|
onSubmit={handleConfigSubmit}
|
|
64
|
-
|
|
64
|
+
initialAccessToken={initialConfig.accessToken || ''}
|
|
65
65
|
initialBaseUrl={initialConfig.baseUrl || ''}
|
|
66
66
|
/>
|
|
67
67
|
);
|
|
@@ -2,17 +2,17 @@ import { useState } from 'react';
|
|
|
2
2
|
import { LogoIcon } from './Icons';
|
|
3
3
|
|
|
4
4
|
interface ConfigStateProps {
|
|
5
|
-
onSubmit: (
|
|
6
|
-
|
|
5
|
+
onSubmit: (accessToken: string, baseUrl: string) => void;
|
|
6
|
+
initialAccessToken?: string;
|
|
7
7
|
initialBaseUrl?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function ConfigState({
|
|
11
11
|
onSubmit,
|
|
12
|
-
|
|
12
|
+
initialAccessToken = '',
|
|
13
13
|
initialBaseUrl = '',
|
|
14
14
|
}: ConfigStateProps) {
|
|
15
|
-
const [
|
|
15
|
+
const [accessToken, setAccessToken] = useState(initialAccessToken);
|
|
16
16
|
const [baseUrl, setBaseUrl] = useState(initialBaseUrl);
|
|
17
17
|
const [error, setError] = useState('');
|
|
18
18
|
|
|
@@ -25,7 +25,7 @@ export function ConfigState({
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
setError('');
|
|
28
|
-
onSubmit(
|
|
28
|
+
onSubmit(accessToken.trim(), baseUrl.trim());
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
return (
|
|
@@ -44,13 +44,13 @@ export function ConfigState({
|
|
|
44
44
|
|
|
45
45
|
<form className="config-form" onSubmit={handleSubmit}>
|
|
46
46
|
<div className="form-group">
|
|
47
|
-
<label htmlFor="eka-
|
|
47
|
+
<label htmlFor="eka-access-token">Access Token</label>
|
|
48
48
|
<input
|
|
49
|
-
id="eka-
|
|
49
|
+
id="eka-access-token"
|
|
50
50
|
type="text"
|
|
51
|
-
value={
|
|
52
|
-
onChange={(e) =>
|
|
53
|
-
placeholder="Enter your
|
|
51
|
+
value={accessToken}
|
|
52
|
+
onChange={(e) => setAccessToken(e.target.value)}
|
|
53
|
+
placeholder="Enter your access token (optional)"
|
|
54
54
|
/>
|
|
55
55
|
</div>
|
|
56
56
|
|
|
@@ -25,11 +25,14 @@ export function useScribeSession(config: ScribeWidgetConfig): UseScribeSessionRe
|
|
|
25
25
|
const startTimeRef = useRef<number>(0);
|
|
26
26
|
const pausedTimeRef = useRef<number>(0);
|
|
27
27
|
|
|
28
|
-
const log = useCallback(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const log = useCallback(
|
|
29
|
+
(...args: unknown[]) => {
|
|
30
|
+
if (config.debug) {
|
|
31
|
+
console.log('[EkaScribe]', ...args);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[config.debug]
|
|
35
|
+
);
|
|
33
36
|
|
|
34
37
|
// Initialize SDK client only when baseUrl is provided
|
|
35
38
|
useEffect(() => {
|
|
@@ -40,8 +43,9 @@ export function useScribeSession(config: ScribeWidgetConfig): UseScribeSessionRe
|
|
|
40
43
|
|
|
41
44
|
const initClient = async () => {
|
|
42
45
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
// Use getInstance instead of new ScribeClient
|
|
47
|
+
clientRef.current = ScribeClient.getInstance({
|
|
48
|
+
accessToken: config.accessToken,
|
|
45
49
|
baseUrl: config.baseUrl,
|
|
46
50
|
debug: config.debug,
|
|
47
51
|
});
|
|
@@ -59,7 +63,7 @@ export function useScribeSession(config: ScribeWidgetConfig): UseScribeSessionRe
|
|
|
59
63
|
clearInterval(timerRef.current);
|
|
60
64
|
}
|
|
61
65
|
};
|
|
62
|
-
}, [config.
|
|
66
|
+
}, [config.accessToken, config.baseUrl, config.debug, log]);
|
|
63
67
|
|
|
64
68
|
const startTimer = useCallback(() => {
|
|
65
69
|
timerRef.current = window.setInterval(() => {
|
|
@@ -87,7 +91,7 @@ export function useScribeSession(config: ScribeWidgetConfig): UseScribeSessionRe
|
|
|
87
91
|
const requestMicrophonePermission = async (): Promise<boolean> => {
|
|
88
92
|
try {
|
|
89
93
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
90
|
-
stream.getTracks().forEach(track => track.stop());
|
|
94
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
91
95
|
return true;
|
|
92
96
|
} catch (error) {
|
|
93
97
|
log('Microphone permission denied', error);
|
|
@@ -126,7 +130,7 @@ export function useScribeSession(config: ScribeWidgetConfig): UseScribeSessionRe
|
|
|
126
130
|
setState('recording');
|
|
127
131
|
|
|
128
132
|
await clientRef.current.startRecording({
|
|
129
|
-
templates: config.templates || ['
|
|
133
|
+
templates: config.templates || ['eka_emr_template'],
|
|
130
134
|
languageHint: config.languageHint,
|
|
131
135
|
});
|
|
132
136
|
|
package/src/index.tsx
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { GetSessionStatusResponse } from 'med-scribe-alliance-ts-sdk';
|
|
2
2
|
|
|
3
|
-
export type WidgetState =
|
|
3
|
+
export type WidgetState =
|
|
4
|
+
| 'idle'
|
|
5
|
+
| 'permission'
|
|
6
|
+
| 'recording'
|
|
7
|
+
| 'paused'
|
|
8
|
+
| 'processing'
|
|
9
|
+
| 'results'
|
|
10
|
+
| 'error';
|
|
4
11
|
|
|
5
12
|
export interface ScribeWidgetConfig {
|
|
6
|
-
|
|
7
|
-
baseUrl
|
|
13
|
+
accessToken?: string;
|
|
14
|
+
baseUrl: string;
|
|
8
15
|
templates?: string[];
|
|
9
16
|
languageHint?: string[];
|
|
10
17
|
position?: { bottom?: number; right?: number; top?: number; left?: number };
|