Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions frontend/overlays/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,33 @@ export function normalizeDisplayName(displayName: string, userName: string): str

return userName
}

export function loadEruda() {
const url = new URL(location.href)
const isDebug = url.searchParams.get('debug')
if (!isDebug) return

const script = document.createElement('script')
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/eruda.min.js'

script.onload = () => {
if (!window.eruda) return
window.eruda.init()
window.eruda.show()
}

script.onerror = () => {
const error = document.createElement('div')
error.textContent = 'Failed to load eruda'
Object.assign(error.style, {
background: 'red',
color: 'white',
textAlign: 'center',
fontWeight: 'bold',
padding: '10px 0',
})
document.body.prepend(error)
}

document.head.append(script)
}
6 changes: 5 additions & 1 deletion frontend/overlays/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import { createApp } from 'vue'
import { urqlClientOptions } from '@/plugins/urql.ts'

import MainApp from './app.vue'
import './style.css'
import { router } from './plugins/router.js'
import { loadEruda } from './helpers.js'
import './style.css'

const app = createApp(MainApp)

app.use(router).use(urql, urqlClientOptions)

app.mount('#app')

// eruda devtools
loadEruda()

// refresh the page when new version comes
document.body.addEventListener('plugin_web_update_notice', () => {
window.location.reload()
Expand Down
6 changes: 0 additions & 6 deletions frontend/overlays/src/pages/alerts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import { useRoute } from 'vue-router'
import { openApi } from '@/api.ts'
import { generateSocketUrlWithParams } from '@/helpers.js'

declare global {
interface Window {
webkitAudioContext: typeof AudioContext
}
}

const queue = ref<Array<{
id: string
channel_id: string
Expand Down
6 changes: 0 additions & 6 deletions frontend/overlays/src/pages/tts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import type { TTSSayMessage } from '@/types.js'
import { useTTSOverlayGraphQL } from '@/composables/tts/use-tts-graphql.js'
import { openApi } from '@/api.js'

declare global {
interface Window {
webkitAudioContext: typeof AudioContext
}
}

const isProcessing = ref(false)
const queueMessages = ref<TTSSayMessage[]>([])
const currentAudioBuffer = ref<AudioBufferSourceNode | null>(null)
Expand Down
8 changes: 5 additions & 3 deletions frontend/overlays/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/// <reference types="vite/client" />

declare global {
interface Window {
webkitAudioContext: typeof AudioContext
}
interface Window {
eruda: any
}
}

/// <reference types="vite/client" />
/// <reference types="vite-svg-loader" />
declare module '*.vue';

export {}
Loading