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
13 changes: 10 additions & 3 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ Los botones de **fragmentos** insertan recetas listas: otro color, sin inclinaci

### Overlays propios

Una capa nueva para el programa de emisión hecha con HTML, CSS y JavaScript: un marco para la cámara, un título animado, un cartel para una escena. Los escribes tú en **Overlays** o se los pides a Claude por MCP (`crear_overlay`); lo que hace el agente aparece en el panel sin recargar.
Una capa nueva para el programa de emisión hecha con HTML, CSS y JavaScript: un marco para la cámara, un título animado, un cartel para una escena. Los escribes tú en **Personalizados** (antes «Overlays»; las URL, la API y las herramientas MCP conservan sus nombres) o se los pides a Claude por MCP (`crear_overlay`); lo que hace el agente aparece en el panel sin recargar. Con campos de ajustes funcionan como widgets propios: un formulario en el panel, sin tocar el código.

| Dónde | Qué hay |
|---|---|
| Panel › **Overlays** | Lista en tarjetas, editor con pestañas HTML, CSS y JavaScript, CSS por tema, vista previa en vivo, ancho y alto, fondo transparente, permisos, copiar URL y borrar |
| Panel › **Personalizados** | Lista en tarjetas, editor con pestañas HTML, CSS, JavaScript y Campos (los campos en JSON), formulario «Valores» generado a partir de los campos, CSS por tema, vista previa en vivo, ancho y alto, fondo transparente, permisos, copiar URL y borrar |
| Programa de emisión | Añade una fuente de navegador con `http://127.0.0.1:4500/custom/<id>` y el tamaño del overlay (también está en la página «Fuentes del programa de emisión», como «Overlay · nombre») |
| Al guardar | El código del overlay recarga las capas abiertas; el CSS del tema y los cambios de tema se aplican en vivo sin recargar el marco |

Expand All @@ -293,8 +293,9 @@ Una capa nueva para el programa de emisión hecha con HTML, CSS y JavaScript: un
| API | Qué hace |
|---|---|
| `antena.on(evento, fn)` | Escucha un evento y devuelve la función para dejar de escuchar. Si ya hay un valor, `fn` se llama al momento con él |
| `antena.state` | Último valor de cada evento (`alert`, `chat`, `viewers`, `widgets`, `interactive`, `theme`, `scene`, `sceneSwitch`); empiezan en `null` |
| `antena.state` | Último valor de cada evento (`alert`, `chat`, `viewers`, `widgets`, `interactive`, `theme`, `scene`, `sceneSwitch`, `settings`); empiezan en `null` |
| `antena.ready` | Promesa que se resuelve cuando ya hay datos: espera antes de leer `antena.state` |
| `antena.settings` | Los ajustes de este overlay (ver «Campos de ajustes» más abajo) |
| `antena.run(tipo, params)` | Pide una acción aprobada: resuelve si se ejecutó y se rechaza con el error del servidor si no |
| `antena.slots.place(huecos, opciones)` / `antena.slots.clear(nombre?)` | Coloca, mueve u oculta widgets reales; borra uno o todos al momento |

Expand Down Expand Up @@ -343,6 +344,12 @@ El agente **pide** permisos al crear o editar; solo tú los **apruebas** en el p

**Seguridad.** El código corre en un `<iframe sandbox>` con origen opaco, en una página aparte: no tiene la API de antena, no puede leer el panel ni abrir el flujo de eventos. Los datos le llegan solo por mensajes de la página que lo aloja, y solo puede pedir de vuelta acciones aprobadas o huecos validados con páginas públicas de Antena.

#### Campos de ajustes

Un overlay puede declarar **campos** para que sus ajustes se editen en un formulario en vez de en el código: `fields` = `[{ key, label, type, default?, options?, min?, max?, step? }]` (hasta 30; `key`: minúsculas, números y `_`, empezando por letra). Tipos: `text` (hasta 2000 caracteres), `number` (`min`/`max`/`step`), `toggle`, `select` (`options`), `color` (`#rgb`, `#rrggbb`, `#rrggbbaa`), `list` (hasta 50 textos) y `media` (el nombre de un archivo de Antena).

La página lee `antena.settings` (`{ key: valor }`, con el valor por defecto del campo si no hay valor; un campo media es la URL absoluta `/media/<archivo>`) o escucha con `antena.on('settings', fn)`. Cambiar valores los aplica en vivo, sin recargar la capa; cambiar los campos la recarga y conserva los valores cuya clave sigue existiendo y encaja. Los valores viajan con la exportación de configuración, no con los temas guardados, y nunca obligan a volver a aprobar las acciones. API: `fields` y `values` en `/api/custom-overlays` (los valores se fusionan con los guardados; `null` borra uno). MCP: `campos` y `valores` en `crear_overlay` y `editar_overlay`.

Por MCP: `listar_overlays`, `ver_overlay`, `crear_overlay`, `editar_overlay`, `borrar_overlay` y `probar_overlay` (manda un evento de ejemplo a una capa abierta).

> «Hazme un overlay propio con el último seguidor en una tarjeta HTML/CSS animada y añádelo al programa de emisión».
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ The **snippets** buttons insert ready-made recipes: another color, no tilt, smal

### Custom overlays

A new layer for the broadcast program made of HTML, CSS and JavaScript: a frame for the camera, an animated title, a card for a scene. You write them in **Overlays**, or ask Claude via MCP (`crear_overlay`); whatever the agent does shows up in the panel without reloading.
A new layer for the broadcast program made of HTML, CSS and JavaScript: a frame for the camera, an animated title, a card for a scene. You write them in **Personalizados** (formerly «Overlays»; URLs, API and MCP tools keep their names), or ask Claude via MCP (`crear_overlay`); whatever the agent does shows up in the panel without reloading. With settings fields they work as custom widgets: a form in the panel, no code changes.

| Where | What you get |
|---|---|
| Panel › **Overlays** | Card list, editor with HTML, CSS and JavaScript tabs, theme-specific CSS, live preview, width and height, transparent background, permissions, copy URL and delete |
| Panel › **Personalizados** | Card list, editor with HTML, CSS, JavaScript and Campos (fields as JSON) tabs, a «Valores» form generated from the fields, theme-specific CSS, live preview, width and height, transparent background, permissions, copy URL and delete |
| Broadcast program | Add a browser source with `http://127.0.0.1:4500/custom/<id>` and the overlay size (it is also on the «Fuentes del programa de emisión» page, as «Overlay · name») |
| On save | Saving overlay code reloads open layers; saving theme-specific CSS or switching themes updates them live without a frame reload |

Expand All @@ -294,8 +294,9 @@ The editor's **CSS de este tema** belongs to the active saved theme. Duplicating
| API | What it does |
|---|---|
| `antena.on(event, fn)` | Listens to an event and returns the function that unsubscribes. If a value already exists, `fn` is called with it right away |
| `antena.state` | Latest value per event (`alert`, `chat`, `viewers`, `widgets`, `interactive`, `theme`, `scene`, `sceneSwitch`); they start as `null` |
| `antena.state` | Latest value per event (`alert`, `chat`, `viewers`, `widgets`, `interactive`, `theme`, `scene`, `sceneSwitch`, `settings`); they start as `null` |
| `antena.ready` | Promise that resolves once there is data: await it before reading `antena.state` |
| `antena.settings` | This overlay's settings (see «Settings fields» below) |
| `antena.run(kind, params)` | Requests an approved action: resolves when it ran, rejects with the server error otherwise |
| `antena.slots.place(slots, options)` / `antena.slots.clear(name?)` | Place, move or hide real widgets; remove one or all immediately |

Expand Down Expand Up @@ -344,6 +345,12 @@ The agent **asks** for permissions when it creates or edits; only you **approve*

**Security.** User code runs in a sandboxed `<iframe>` with an opaque origin, on a separate page: it has no antena API, cannot read the panel and cannot open the event stream. Data only reaches it through messages from the page hosting it, and it can only ask back for approved actions or validated slots containing public Antena pages.

#### Settings fields

An overlay can declare **fields** so its settings are edited in a form instead of in code: `fields` = `[{ key, label, type, default?, options?, min?, max?, step? }]` (up to 30; `key`: lowercase letters, digits and `_`, starting with a letter). Types: `text` (up to 2000 characters), `number` (`min`/`max`/`step`), `toggle`, `select` (`options`), `color` (`#rgb`, `#rrggbb`, `#rrggbbaa`), `list` (up to 50 texts) and `media` (the name of an Antena file).

The page reads `antena.settings` (`{ key: value }`, with the field default when there is no value; a media field is the absolute `/media/<file>` URL) or listens with `antena.on('settings', fn)`. Changing values applies them live, without reloading the layer; changing the fields reloads it and keeps the values whose key still exists and still fits. Values travel with the configuration export, not with saved themes, and never require approving the actions again. API: `fields` and `values` on `/api/custom-overlays` (values merge with the stored ones; `null` removes one). MCP: `campos` and `valores` in `crear_overlay` and `editar_overlay`.

Over MCP: `listar_overlays`, `ver_overlay`, `crear_overlay`, `editar_overlay`, `borrar_overlay` and `probar_overlay` (fires a sample event at one open layer).

> «Make me a custom overlay with the latest follower as an animated HTML/CSS card and add it to the broadcast program».
Expand Down
6 changes: 6 additions & 0 deletions app/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ export interface CustomOverlay {
// porque un overlay guardado antes de S11 no los trae (el servidor los normaliza al leerlo).
requestedPermissions?: string[]; permissions?: string[];
approvedAt?: number; approvedUpdatedAt?: number;
// #344: declared settings fields and their values (the server normalizes old overlays to [] / {}).
fields?: CustomOverlayField[]; values?: Record<string, unknown>;
}
export interface CustomOverlayField {
key: string; label: string; type: 'text' | 'number' | 'toggle' | 'select' | 'color' | 'list' | 'media';
default?: unknown; options?: string[]; min?: number; max?: number; step?: number;
}

// ---------- récord de espectadores (src/viewers.mjs) ----------
Expand Down
2 changes: 1 addition & 1 deletion app/src/panel/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function Sidebar({ current }: { current: string }) {
{ href: '#/comandos', label: 'Comandos de chat', tail: num(s.config.commands?.length) },
{ href: '#/mensajes', label: 'Mensajes programados', tail: num(s.config.timers?.length) },
{ href: '#/widgets', label: 'Widgets', tail: widgetTail },
{ href: '#/overlays', label: 'Overlays', tail: num((s.customOverlays || []).length) },
{ href: '#/overlays', label: 'Personalizados', tail: num((s.customOverlays || []).length) },
{ href: '#/atajos', label: 'Atajos y Stream Deck', tail: num(s.config.shortcuts?.length) },
]],
['produccion', 'Producción', [
Expand Down
Loading
Loading