scribe-widget 1.0.1 → 1.0.3
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 +16 -0
- package/dist/scribe-widget.umd.js +1 -1
- package/package.json +1 -1
- package/src/App.tsx +2 -4
- package/src/index.tsx +24 -0
- package/src/types.ts +2 -2
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -17,7 +17,7 @@ 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<{ apiKey
|
|
20
|
+
const [credentials, setCredentials] = useState<{ apiKey?: string; baseUrl: string } | null>(
|
|
21
21
|
initialConfig.baseUrl ? { apiKey: initialConfig.apiKey, baseUrl: initialConfig.baseUrl } : null
|
|
22
22
|
);
|
|
23
23
|
|
|
@@ -90,9 +90,7 @@ export function App({ config: initialConfig, onClose }: AppProps) {
|
|
|
90
90
|
return <ProcessingState />;
|
|
91
91
|
|
|
92
92
|
case 'results':
|
|
93
|
-
return result ?
|
|
94
|
-
<ResultsState result={result} onNewRecording={reset} />
|
|
95
|
-
) : null;
|
|
93
|
+
return result ? <ResultsState result={result} onNewRecording={reset} /> : null;
|
|
96
94
|
|
|
97
95
|
case 'error':
|
|
98
96
|
return <ErrorState message={errorMessage} onRetry={reset} />;
|
package/src/index.tsx
CHANGED
|
@@ -114,3 +114,27 @@ const EkaScribe = {
|
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
export default EkaScribe;
|
|
117
|
+
|
|
118
|
+
// Auto-initialize when script loads in browser
|
|
119
|
+
// Widget will show config form since no apiKey/baseUrl provided
|
|
120
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
121
|
+
const autoInit = () => {
|
|
122
|
+
// Don't auto-init if already initialized or if data-no-auto-init attribute is present
|
|
123
|
+
const scriptTag = document.currentScript || document.querySelector('script[src*="scribe-widget"]');
|
|
124
|
+
if (scriptTag?.hasAttribute('data-no-auto-init')) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!widgetInstance) {
|
|
129
|
+
init({});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Run after DOM is ready
|
|
134
|
+
if (document.readyState === 'loading') {
|
|
135
|
+
document.addEventListener('DOMContentLoaded', autoInit);
|
|
136
|
+
} else {
|
|
137
|
+
// DOM already loaded, init immediately
|
|
138
|
+
autoInit();
|
|
139
|
+
}
|
|
140
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { GetSessionStatusResponse } from 'med-scribe-alliance-ts-sdk';
|
|
|
3
3
|
export type WidgetState = 'idle' | 'permission' | 'recording' | 'paused' | 'processing' | 'results' | 'error';
|
|
4
4
|
|
|
5
5
|
export interface ScribeWidgetConfig {
|
|
6
|
-
apiKey
|
|
7
|
-
baseUrl
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
8
|
templates?: string[];
|
|
9
9
|
languageHint?: string[];
|
|
10
10
|
position?: { bottom?: number; right?: number; top?: number; left?: number };
|