openpencil/vite/automation.ts
2026-05-18 18:58:30 +03:00

18 lines
614 B
TypeScript

import { randomUUID } from 'node:crypto'
import { automationPlugin } from '../src/app/automation/bridge/vite-plugin'
const devAutomationAuthToken = randomUUID()
export function localAutomationToken(command: string): string | null {
return command === 'serve' ? devAutomationAuthToken : null
}
export function automationCorsOrigin(host: string | undefined): string {
return host ? `http://${host}:1420` : 'http://localhost:1420'
}
export function openPencilAutomationPlugin(command: string, host: string | undefined) {
return automationPlugin(localAutomationToken(command), automationCorsOrigin(host))
}