fix: Add missing browser-api.js functions for browser mode
- Add getConfig() for app initialization - Add openInBrowser() (no-op in browser mode) - Add onTranscriptionResult() for compatibility - Add onStreamStarted() for compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,39 @@ let streamingSocket = null;
|
||||
|
||||
// Browser mode API implementation
|
||||
const browserAPI = {
|
||||
// Get app configuration (browser mode fetches from backend or uses defaults)
|
||||
getConfig: async () => {
|
||||
try {
|
||||
// Try to fetch config from backend
|
||||
const response = await fetch(`${API_BASE}/config/settings.js`);
|
||||
if (response.ok) {
|
||||
// settings.js exports a config object, parse it
|
||||
const text = await response.text();
|
||||
// Simple extraction of the config object
|
||||
const match = text.match(/export\s+const\s+config\s*=\s*(\{[\s\S]*?\});/);
|
||||
if (match) {
|
||||
// Use eval cautiously here - it's our own config file
|
||||
const configStr = match[1];
|
||||
return eval('(' + configStr + ')');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('[Browser Mode] Could not load config from server, using defaults');
|
||||
}
|
||||
|
||||
// Return browser mode defaults
|
||||
return {
|
||||
apiBaseUrl: `${window.location.origin}/api`,
|
||||
uploadTimeout: 600000,
|
||||
appTitle: "Meeting Assistant",
|
||||
whisper: {
|
||||
model: "medium",
|
||||
device: "cpu",
|
||||
compute: "int8"
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
// Navigate to a page
|
||||
navigate: (page) => {
|
||||
const pageMap = {
|
||||
@@ -223,6 +256,24 @@ const browserAPI = {
|
||||
} catch {
|
||||
return { ready: false };
|
||||
}
|
||||
},
|
||||
|
||||
// Open in browser - no-op in browser mode (already in browser)
|
||||
openInBrowser: async () => {
|
||||
console.log('[Browser Mode] Already running in browser');
|
||||
return { success: true, url: window.location.href };
|
||||
},
|
||||
|
||||
// Legacy transcription result listener (for file-based mode)
|
||||
onTranscriptionResult: (callback) => {
|
||||
// Not used in browser streaming mode, but provide for compatibility
|
||||
console.log('[Browser Mode] onTranscriptionResult registered (legacy)');
|
||||
},
|
||||
|
||||
// Stream started listener
|
||||
onStreamStarted: (callback) => {
|
||||
// HTTP-based streaming doesn't have this event
|
||||
console.log('[Browser Mode] onStreamStarted registered');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user