|
|
|
|
import { invoke } from '@tauri-apps/api/core';
|
|
|
|
|
import { fetch } from '@tauri-apps/plugin-http';
|
|
|
|
|
|
|
|
|
|
export const OSC_ADDRESS={
|
|
|
|
|
LIGHT: '/light',
|
|
|
|
|
STATUS: '/status',
|
|
|
|
|
INPUT: '/input',
|
|
|
|
|
COUNTDOWN: '/countdown',
|
|
|
|
|
VOLUME: '/volume',
|
|
|
|
|
SCRIPT: '/script',
|
|
|
|
|
SUMMARY: '/summary',
|
|
|
|
|
PROMPT: '/prompt',
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export async function sendOsc(key, message){
|
|
|
|
|
|
|
|
|
|
if(message === undefined || message === null || message === '') {
|
|
|
|
|
console.warn('sendOsc: message is empty, skipping');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
console.log(`Sending OSC message: ${key} -> ${message}`);
|
|
|
|
|
await invoke('send_osc_message', {
|
|
|
|
|
key: key,
|
|
|
|
|
message: message.toString(),
|
|
|
|
|
host:`0.0.0.0:0`,
|
|
|
|
|
target: '127.0.0.1:9000',
|
|
|
|
|
});
|
|
|
|
|
}catch (error){
|
|
|
|
|
console.error('Error sending OSC message:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send to python fastapi
|
|
|
|
|
export async function updatePrompt(prompt) {
|
|
|
|
|
console.log(`Updating prompt: ${prompt}`);
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
await fetch('http://localhost:34800/api/update/prompt', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({ prompt })
|
|
|
|
|
});
|
|
|
|
|
}catch(error){
|
|
|
|
|
console.error('Error updating prompt:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|