scribe-widget 1.0.0 → 1.0.2
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/.prettierrc +7 -0
- package/FLOW.md +94 -0
- package/README.md +1 -0
- package/dist/scribe-widget.es.js +1102 -1141
- package/dist/scribe-widget.umd.js +12 -12
- package/package.json +4 -2
- package/src/App.tsx +2 -4
- package/src/index.tsx +35 -18
- package/src/types.ts +2 -2
- package/vite.config.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scribe-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Floating panel widget for medical transcription using eka.scribe",
|
|
5
5
|
"main": "dist/scribe-widget.umd.js",
|
|
6
6
|
"module": "dist/scribe-widget.es.js",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"dev": "vite",
|
|
10
10
|
"build": "vite build",
|
|
11
11
|
"preview": "vite preview",
|
|
12
|
-
"typecheck": "tsc --noEmit"
|
|
12
|
+
"typecheck": "tsc --noEmit",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
13
15
|
},
|
|
14
16
|
"dependencies": {
|
|
15
17
|
"med-scribe-alliance-ts-sdk": "1.0.2",
|
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
|
@@ -87,10 +87,10 @@ class ScribeWidget {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// Global initialization function
|
|
90
|
+
// Global initialization function
|
|
91
91
|
let widgetInstance: ScribeWidget | null = null;
|
|
92
92
|
|
|
93
|
-
function
|
|
93
|
+
function init(config: ScribeWidgetConfig = {} as ScribeWidgetConfig): ScribeWidget {
|
|
94
94
|
if (widgetInstance) {
|
|
95
95
|
widgetInstance.unmount();
|
|
96
96
|
}
|
|
@@ -99,25 +99,42 @@ function initEkaScribe(config: ScribeWidgetConfig): ScribeWidget {
|
|
|
99
99
|
return widgetInstance;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function
|
|
102
|
+
function getInstance(): ScribeWidget | null {
|
|
103
103
|
return widgetInstance;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
(window as Window & { EkaScribe?: unknown }).EkaScribe = {
|
|
109
|
-
init: initEkaScribe,
|
|
110
|
-
getInstance: getEkaScribe,
|
|
111
|
-
Widget: ScribeWidget,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Named exports for ES module usage
|
|
116
|
-
export { ScribeWidget, initEkaScribe as init, getEkaScribe as getInstance };
|
|
106
|
+
// Named exports - these become window.EkaScribe.init, window.EkaScribe.getInstance, etc. in UMD
|
|
107
|
+
export { ScribeWidget, init, getInstance };
|
|
117
108
|
|
|
118
|
-
// Default export for module
|
|
119
|
-
|
|
120
|
-
init
|
|
121
|
-
getInstance
|
|
109
|
+
// Default export for ES module convenience
|
|
110
|
+
const EkaScribe = {
|
|
111
|
+
init,
|
|
112
|
+
getInstance,
|
|
122
113
|
Widget: ScribeWidget,
|
|
123
114
|
};
|
|
115
|
+
|
|
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 };
|
package/vite.config.ts
CHANGED
|
@@ -12,8 +12,9 @@ export default defineConfig({
|
|
|
12
12
|
formats: ['umd', 'es'],
|
|
13
13
|
},
|
|
14
14
|
rollupOptions: {
|
|
15
|
-
// Don't externalize React - bundle it for standalone use
|
|
16
15
|
output: {
|
|
16
|
+
// Use named exports to avoid the .default issue
|
|
17
|
+
exports: 'named',
|
|
17
18
|
globals: {},
|
|
18
19
|
},
|
|
19
20
|
},
|