File tree Expand file tree Collapse file tree 10 files changed +43
-52
lines changed
Expand file tree Collapse file tree 10 files changed +43
-52
lines changed Original file line number Diff line number Diff line change 1- import type { AppConfig } from './lib/types' ;
1+ export interface AppConfig {
2+ pageTitle : string ;
3+ pageDescription : string ;
4+ companyName : string ;
5+
6+ supportsChatInput : boolean ;
7+ supportsVideoInput : boolean ;
8+ supportsScreenShare : boolean ;
9+ isPreConnectBufferEnabled : boolean ;
10+
11+ logo : string ;
12+ startButtonText : string ;
13+ accent ?: string ;
14+ logoDark ?: string ;
15+ accentDark ?: string ;
16+
17+ sandboxId ?: string ;
18+ agentName ?: string ;
19+ }
220
321export const APP_CONFIG_DEFAULTS : AppConfig = {
422 companyName : 'LiveKit' ,
Original file line number Diff line number Diff line change 11import { NextResponse } from 'next/server' ;
22import { AccessToken , type AccessTokenOptions , type VideoGrant } from 'livekit-server-sdk' ;
33import { RoomConfiguration } from '@livekit/protocol' ;
4- import type { ConnectionDetails } from '@/lib/types ' ;
4+ import type { ConnectionDetails } from '@/hooks/useConnectionDetails ' ;
55
66// NOTE: you are expected to define the following environment variables in `.env.local`:
77const API_KEY = process . env . LIVEKIT_API_KEY ;
Original file line number Diff line number Diff line change 33import React from 'react' ;
44import { Room } from 'livekit-client' ;
55import { RoomContext } from '@livekit/components-react' ;
6+ import { AppConfig } from '@/app-config' ;
67import { toastAlert } from '@/components/livekit/alert-toast' ;
78import useConnectionDetails from '@/hooks/useConnectionDetails' ;
8- import { AppConfig } from '@/lib/types' ;
99
1010export function RoomProvider ( {
1111 appConfig,
Original file line number Diff line number Diff line change 22
33import { AnimatePresence , motion } from 'motion/react' ;
44import { RoomAudioRenderer , RoomContext , StartAudio } from '@livekit/components-react' ;
5+ import type { AppConfig } from '@/app-config' ;
56import { SessionView } from '@/components/app/session-view' ;
67import { Welcome } from '@/components/app/welcome' ;
78import { Toaster } from '@/components/livekit/toaster' ;
89import { useRoom } from '@/hooks/useRoom' ;
9- import type { AppConfig } from '@/lib/types' ;
1010
1111const MotionWelcome = motion . create ( Welcome ) ;
1212const MotionSessionView = motion . create ( SessionView ) ;
Original file line number Diff line number Diff line change 22
33import React , { useState } from 'react' ;
44import { motion } from 'motion/react' ;
5+ import type { AppConfig } from '@/app-config' ;
56import { ChatTranscript } from '@/components/app/chat-transcript' ;
67import { PreConnectMessage } from '@/components/app/preconnect-message' ;
78import { TileLayout } from '@/components/app/tile-layout' ;
@@ -13,7 +14,6 @@ import { Skrim } from '@/components/livekit/skrim';
1314import { useChatTranscriptions } from '@/hooks/useChatAndTranscription' ;
1415import { useConnectionTimeout } from '@/hooks/useConnectionTimout' ;
1516import { useDebugMode } from '@/hooks/useDebug' ;
16- import type { AppConfig } from '@/lib/types' ;
1717import { cn } from '@/lib/utils' ;
1818import { ScrollArea } from '../livekit/scroll-area' ;
1919
Original file line number Diff line number Diff line change 22
33import { useEffect , useState } from 'react' ;
44import { MonitorIcon , MoonIcon , SunIcon } from '@phosphor-icons/react' ;
5- import type { ThemeMode } from '@/lib/types' ;
65import { THEME_MEDIA_QUERY , THEME_STORAGE_KEY , cn } from '@/lib/utils' ;
76
87const THEME_SCRIPT = `
@@ -23,6 +22,8 @@ const THEME_SCRIPT = `
2322 . replace ( / \n / g, '' )
2423 . replace ( / \s + / g, ' ' ) ;
2524
25+ export type ThemeMode = 'dark' | 'light' | 'system' ;
26+
2627function applyTheme ( theme : ThemeMode ) {
2728 const doc = document . documentElement ;
2829
Original file line number Diff line number Diff line change 11import { useCallback , useEffect , useState } from 'react' ;
22import { decodeJwt } from 'jose' ;
3- import type { AppConfig , ConnectionDetails } from '@/lib/types ' ;
3+ import type { AppConfig } from '@/app-config ' ;
44
55const ONE_MINUTE_IN_MILLISECONDS = 60 * 1000 ;
66
7+ export type ConnectionDetails = {
8+ serverUrl : string ;
9+ roomName : string ;
10+ participantName : string ;
11+ participantToken : string ;
12+ } ;
13+
714export default function useConnectionDetails ( appConfig : AppConfig ) {
815 // Generate room connection details, including:
916 // - A random Room name
Original file line number Diff line number Diff line change 11import { useEffect , useMemo , useState } from 'react' ;
22import { Room , RoomEvent } from 'livekit-client' ;
3+ import { AppConfig } from '@/app-config' ;
34import { toastAlert } from '@/components/livekit/alert-toast' ;
45import useConnectionDetails from '@/hooks/useConnectionDetails' ;
5- import { AppConfig } from '@/lib/types' ;
66
77export function useRoom ( appConfig : AppConfig ) {
88 const room = useMemo ( ( ) => new Room ( ) , [ ] ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,14 +2,22 @@ import { cache } from 'react';
22import { type ClassValue , clsx } from 'clsx' ;
33import { twMerge } from 'tailwind-merge' ;
44import { APP_CONFIG_DEFAULTS } from '@/app-config' ;
5- import type { AppConfig , SandboxConfig } from './types ' ;
5+ import type { AppConfig } from '@/app-config ' ;
66
77export const CONFIG_ENDPOINT = process . env . NEXT_PUBLIC_APP_CONFIG_ENDPOINT ;
88export const SANDBOX_ID = process . env . SANDBOX_ID ;
99
1010export const THEME_STORAGE_KEY = 'theme-mode' ;
1111export const THEME_MEDIA_QUERY = '(prefers-color-scheme: dark)' ;
1212
13+ export interface SandboxConfig {
14+ [ key : string ] :
15+ | { type : 'string' ; value : string }
16+ | { type : 'number' ; value : number }
17+ | { type : 'boolean' ; value : boolean }
18+ | null ;
19+ }
20+
1321export function cn ( ...inputs : ClassValue [ ] ) {
1422 return twMerge ( clsx ( inputs ) ) ;
1523}
You can’t perform that action at this time.
0 commit comments