openpencil/vite/automation.ts
Danila Poyarkov 7f91594d0c refactor: standardize acronym casing
- Rename first-party API, RPC, JSON, CORS, SVG, JSX, and related identifiers to preserve acronym casing
- Keep upstream and serialized boundary names unchanged
- Add a lint guardrail and migration notes for exported APIs
2026-08-10 15:48:16 +03:00

19 lines
685 B
TypeScript

import { randomUUID } from 'node:crypto'
import process from 'node:process'
import { automationPlugin } from '../src/app/automation/bridge/vite-plugin'
const devAutomationAuthToken = process.env.OPENPENCIL_DEV_TOKEN ?? 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))
}