Comparar commits
18 Commits
| Autor | SHA1 | Fecha | |
|---|---|---|---|
|
|
b4c9418b14 | ||
|
|
f162f5ae09 | ||
|
|
37403791f6 | ||
|
|
29b88ed97f | ||
|
|
0df9bd1374 | ||
|
|
2595faf372 | ||
|
|
cac69dd7be | ||
|
|
3798970f74 | ||
|
|
29f0b47371 | ||
|
|
b18c155b89 | ||
|
|
424f401ad6 | ||
|
|
f6eea75404 | ||
|
|
44898da17c | ||
|
|
2c872ace7d | ||
|
|
fb4a441fa0 | ||
|
|
9489d6cc58 | ||
|
|
d302591c25 | ||
|
|
e7c69fe0ea |
102
.github/workflows/check.yml
vendido
Archivo normal
102
.github/workflows/check.yml
vendido
Archivo normal
@@ -0,0 +1,102 @@
|
|||||||
|
name: Verificar compilación (sin publicar)
|
||||||
|
|
||||||
|
# Comprueba que el shell COMPILA en Windows y macOS sin construir instaladores ni tocar
|
||||||
|
# Releases. Sirve para revisar un cambio en una rama antes de etiquetar la versión: el
|
||||||
|
# workflow de publicar solo se dispara con etiquetas `v*`, así que hasta ahora no había
|
||||||
|
# forma de saber si algo compilaba sin publicarlo.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read # solo lee el repo: no crea releases ni sube nada
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform: [windows-latest, macos-latest]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: Clonar repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Instalar Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Instalar Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: clippy
|
||||||
|
|
||||||
|
- name: Cache de Rust
|
||||||
|
uses: swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: src-tauri
|
||||||
|
|
||||||
|
- name: Instalar dependencias
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
# build.rs de Tauri valida que existan los iconos que declara tauri.conf.json.
|
||||||
|
- name: Generar iconos (desde app-icon.png)
|
||||||
|
run: npm run icons
|
||||||
|
|
||||||
|
- name: cargo check
|
||||||
|
working-directory: src-tauri
|
||||||
|
run: cargo check --all-targets
|
||||||
|
|
||||||
|
# Avisa de errores reales de Clippy sin tumbar la verificación por avisos de estilo.
|
||||||
|
- name: cargo clippy (informativo)
|
||||||
|
working-directory: src-tauri
|
||||||
|
continue-on-error: true
|
||||||
|
run: cargo clippy --all-targets
|
||||||
|
|
||||||
|
# Instalador de PRUEBA para Windows. Queda colgado de la ejecución como artifact y no
|
||||||
|
# toca Releases ni el updater: sirve para VER el cambio funcionando antes de publicárselo
|
||||||
|
# a todo el equipo, que es irreversible en la práctica (las apps se actualizan solas).
|
||||||
|
instalador-prueba:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Clonar repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Instalar Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Instalar Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Cache de Rust
|
||||||
|
uses: swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: src-tauri
|
||||||
|
|
||||||
|
- name: Instalar dependencias
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: Generar iconos (desde app-icon.png)
|
||||||
|
run: npm run icons
|
||||||
|
|
||||||
|
# La firma hace falta porque tauri.conf.json pide artefactos de updater; el .exe se
|
||||||
|
# queda igualmente aquí, sin publicarse en ningún sitio.
|
||||||
|
- name: Construir el instalador (NSIS)
|
||||||
|
env:
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||||
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||||
|
run: npm run tauri build -- --bundles nsis
|
||||||
|
|
||||||
|
- name: Guardar el instalador como artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: instalador-windows-prueba
|
||||||
|
path: src-tauri/target/release/bundle/nsis/*.exe
|
||||||
|
retention-days: 14
|
||||||
62
README.md
62
README.md
@@ -12,6 +12,14 @@ NAS. Esto le da al equipo un cliente nativo de verdad en Windows y Mac:
|
|||||||
la app** — antes morían en silencio. También ⌘/Ctrl+clic y clic central.
|
la app** — antes morían en silencio. También ⌘/Ctrl+clic y clic central.
|
||||||
Atajos: ⌘/Ctrl+T nueva, ⌘/Ctrl+W cerrar, Ctrl+Tab rotar, ⌘/Ctrl+1…9 ir a la n.
|
Atajos: ⌘/Ctrl+T nueva, ⌘/Ctrl+W cerrar, Ctrl+Tab rotar, ⌘/Ctrl+1…9 ir a la n.
|
||||||
La sesión (pestañas abiertas, activa) **se restaura** al reabrir.
|
La sesión (pestañas abiertas, activa) **se restaura** al reabrir.
|
||||||
|
- **La barra de pestañas ES la fila del título** (v1.6.0), en Windows y en macOS:
|
||||||
|
no se gasta una franja entera en repetir el nombre de la app. En Windows la
|
||||||
|
ventana va sin decoración y la propia barra dibuja los botones minimizar /
|
||||||
|
maximizar / cerrar; en macOS el semáforo lo sigue pintando el sistema y la barra
|
||||||
|
le deja su hueco. El doble clic en el hueco libre maximiza y restaura.
|
||||||
|
- **Colores de pestaña** (v1.6.0): clic derecho sobre una pestaña ▸ **Color**, con
|
||||||
|
la misma paleta de nueve tonos que usa Chrome para sus grupos. Sirve para agrupar
|
||||||
|
de un vistazo (todo lo de un cliente en verde) y **se guarda con la sesión**.
|
||||||
- **Zoom de interfaz**: ⌘/Ctrl `+` / `−` / `0` y Ctrl+rueda, con indicador en la
|
- **Zoom de interfaz**: ⌘/Ctrl `+` / `−` / `0` y Ctrl+rueda, con indicador en la
|
||||||
barra y **persistencia** entre sesiones (50%–250%).
|
barra y **persistencia** entre sesiones (50%–250%).
|
||||||
- **Documentos dentro de la app**: los visores/editores del propio servidor
|
- **Documentos dentro de la app**: los visores/editores del propio servidor
|
||||||
@@ -31,6 +39,27 @@ NAS. Esto le da al equipo un cliente nativo de verdad en Windows y Mac:
|
|||||||
resultado. Es un popup nativo del sistema, igual en Windows y macOS, y vive
|
resultado. Es un popup nativo del sistema, igual en Windows y macOS, y vive
|
||||||
solo en el shell (la web app no se toca).
|
solo en el shell (la web app no se toca).
|
||||||
|
|
||||||
|
- **Rastreador de trabajo efectivo** (v1.8.0, `src-tauri/src/tracker.rs`): mide
|
||||||
|
cuánto tiempo se trabaja de verdad y en qué aplicación, y lo publica en
|
||||||
|
**Reportes → Equipo** del servidor. Cada 5 s mira la ventana al frente y si
|
||||||
|
hubo entrada de ratón/teclado; **con 3 minutos sin entrada deja de contar**
|
||||||
|
(eso cubre también pantalla bloqueada y suspensión). Sube lotes cada 5 min a
|
||||||
|
`POST /api/tracker`; sin red, la cola espera en disco y reintenta.
|
||||||
|
- **Qué NO registra, a propósito:** ni qué teclas se pulsan (solo compara una
|
||||||
|
huella de posición del ratón y cuántas teclas hay presionadas), ni
|
||||||
|
pantallazos, ni el contenido de nada, ni los procesos de fondo.
|
||||||
|
- **Se ve y se pausa**: el menú de la bandeja dice el estado («registrando»,
|
||||||
|
«inactivo», «en pausa») y pausa/reanuda de un toque.
|
||||||
|
- **Se vincula** desde el servidor: Ajustes ▸ Perfil ▸ *Vincular este equipo*,
|
||||||
|
**estando dentro de esta app**. El servidor genera el token del equipo y se
|
||||||
|
lo entrega al sensor por el evento `ls-tracker-token`; el secreto nunca se
|
||||||
|
enseña ni se copia a mano. Revocar el equipo (misma pantalla) lo corta al
|
||||||
|
instante: el siguiente lote recibe 401, el sensor tira el token y la bandeja
|
||||||
|
vuelve a «sin vincular».
|
||||||
|
- En **macOS** el sistema pide permiso de *Accesibilidad* la primera vez (para
|
||||||
|
leer el título de la ventana al frente); sin él, el sensor mide tiempo pero
|
||||||
|
no sabe decir en qué app.
|
||||||
|
|
||||||
La barra de pestañas vive en `dist/index.html` (webview local «chrome»); las
|
La barra de pestañas vive en `dist/index.html` (webview local «chrome»); las
|
||||||
pestañas son webviews hijos `tab-*`. Shell ↔ Rust se hablan por eventos `ls-*`.
|
pestañas son webviews hijos `tab-*`. Shell ↔ Rust se hablan por eventos `ls-*`.
|
||||||
|
|
||||||
@@ -133,22 +162,29 @@ el de Mac a la vez, así ambas plataformas van siempre sincronizadas.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Actualización automática (opcional, recomendable a futuro)
|
## Actualización automática (ACTIVA)
|
||||||
|
|
||||||
Hoy, para actualizar, el equipo descarga el nuevo instalador del Release y lo
|
Las apps ya instaladas **se actualizan solas**: el updater consulta el `latest.json`
|
||||||
reinstala encima. Para que las apps ya instaladas se actualicen solas, Tauri trae
|
que publica cada Release, y los instaladores se firman en el CI con la clave privada
|
||||||
un *updater* (funciona igual en Windows y Mac). Para activarlo (paso futuro):
|
guardada como secret del repo (`TAURI_SIGNING_PRIVATE_KEY`). También se puede forzar
|
||||||
|
la comprobación con clic en la versión de la barra, o desde el menú ⋮ ▸ *Buscar
|
||||||
|
actualización…*.
|
||||||
|
|
||||||
1. Genera el par de claves de firma:
|
> ⚠️ De ahí se sigue algo que conviene tener presente: **un commit en `main` no le
|
||||||
```bash
|
> llega a nadie**. Mientras no exista la etiqueta `vX.Y.Z`, el CI no construye nada y
|
||||||
npm run tauri signer generate -- -w ~/.tauri/labstream.key
|
> el updater no ve versión nueva. Y al revés: publicar una etiqueta **actualiza la app
|
||||||
```
|
> de todo el equipo**, así que no es un paso que se dé a la ligera.
|
||||||
2. Añade el `plugin-updater` y la clave pública en `tauri.conf.json`, y guarda la
|
|
||||||
clave privada como **secret** en GitHub (`TAURI_SIGNING_PRIVATE_KEY`).
|
|
||||||
3. Apunta el updater al `latest.json` que publica el Release.
|
|
||||||
|
|
||||||
Se deja sin activar a propósito para que la **primera** versión compile sin
|
## Probar un cambio antes de publicarlo
|
||||||
configuración extra.
|
|
||||||
|
`.github/workflows/check.yml` corre en cualquier rama que no sea `main` y **no publica
|
||||||
|
nada**:
|
||||||
|
|
||||||
|
- `cargo check` en Windows y macOS — comprueba que compila en las dos.
|
||||||
|
- Un job aparte deja el **instalador `.exe` de prueba** como *artifact* de la ejecución
|
||||||
|
(14 días), para instalarlo encima y ver el cambio funcionando de verdad.
|
||||||
|
|
||||||
|
Es la forma de mirar un cambio visual —la barra, los colores— sin sacárselo al equipo.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
364
dist/index.html
vendido
364
dist/index.html
vendido
@@ -7,37 +7,69 @@
|
|||||||
<!--
|
<!--
|
||||||
Barra de pestañas del shell de escritorio (webview "chrome", local).
|
Barra de pestañas del shell de escritorio (webview "chrome", local).
|
||||||
Habla con Rust por eventos (__TAURI__.event):
|
Habla con Rust por eventos (__TAURI__.event):
|
||||||
recibe ls-tabs {tabs:[{label,title,active}], zoom}
|
recibe ls-tabs {tabs:[{label,title,url,loading,active,color}], zoom, version,
|
||||||
emite ls-ready, ls-new-tab, ls-activate, ls-close-tab, ls-reload, ls-zoom, ls-cycle, ls-activate-n
|
mac, win, maximized, dark}
|
||||||
|
emite ls-ready, ls-new-tab, ls-activate, ls-close-tab, ls-reload, ls-zoom, ls-cycle,
|
||||||
|
ls-activate-n, ls-nav, ls-menu, ls-check-update, ls-tab-menu, ls-reorder
|
||||||
|
En macOS la ventana lleva el título en OVERLAY: esta barra ES la fila del título, así que
|
||||||
|
deja libre el hueco del semáforo (clase `mac`) y el espacio vacío arrastra la ventana
|
||||||
|
(`data-tauri-drag-region`). En Windows hay título nativo aparte y no se reserva nada.
|
||||||
-->
|
-->
|
||||||
<style>
|
<style>
|
||||||
/* Paleta estilo Chrome: la barra es una FRANJA más oscura y la pestaña activa es una
|
/* La barra se pinta del color de la APP, no del gris de Chrome: blanca en tema claro y
|
||||||
tarjeta del color del contenido que se funde con él (sin línea debajo). */
|
negra en oscuro, para que la ventana se lea como una sola pieza y no como una franja
|
||||||
|
de navegador pegada encima.
|
||||||
|
El truco de Chrome se conserva igual —la pestaña activa es una tarjeta del color del
|
||||||
|
CONTENIDO que se funde con él—, solo que ahora el contraste va al revés en oscuro: la
|
||||||
|
franja es más negra que el contenido, así que la activa destaca por ser más clara. La
|
||||||
|
diferencia es sutil a propósito; quien la marca de verdad es el borde inferior, que la
|
||||||
|
pestaña activa tapa con su propio fondo. */
|
||||||
:root {
|
:root {
|
||||||
--bg: #dee1e6; /* franja de pestañas (Chrome claro) */
|
--bg: #f4f5f7; /* franja: casi blanca, del tono de la app en claro */
|
||||||
--fg: #45474a;
|
--fg: #45474a;
|
||||||
--muted: #5f6368;
|
--muted: #5f6368;
|
||||||
--tab-active-bg: #ffffff;
|
--tab-active-bg: #ffffff; /* mismo fondo que la app → pestaña fundida con el contenido */
|
||||||
--tab-active-fg: #202124;
|
--tab-active-fg: #202124;
|
||||||
--accent: #6366f1; /* indigo-500, color de Labstream */
|
--accent: #F47A20; /* NARANJA Labstream (el índigo de antes no era de la marca) */
|
||||||
--border: #c9ccd1; /* línea bajo la barra (la tapa la pestaña activa) */
|
--border: #dcdee1; /* línea bajo la barra (la tapa la pestaña activa) */
|
||||||
--hover: rgba(255, 255, 255, 0.55); /* píldora de hover en pestañas inactivas */
|
/* Sobre una franja casi blanca, un hover blanco no se vería: aquí oscurece. */
|
||||||
|
--hover: rgba(0, 0, 0, 0.06);
|
||||||
--btn-hover: rgba(0, 0, 0, 0.08);
|
--btn-hover: rgba(0, 0, 0, 0.08);
|
||||||
--sep: rgba(0, 0, 0, 0.22); /* separador fino entre pestañas inactivas */
|
--sep: rgba(0, 0, 0, 0.22); /* separador fino entre pestañas inactivas */
|
||||||
}
|
}
|
||||||
|
/* ── Quién decide el tema ──
|
||||||
|
La APP, no Windows: la web elige su modo con su propio botón (clase `dark` en su
|
||||||
|
<html>, defaultTheme claro, sin seguir al sistema), así que obedecer aquí al
|
||||||
|
prefers-color-scheme del sistema pintaba la barra negra sobre una app clara — el
|
||||||
|
bug de siempre. El script inyectado reporta el tema real, Rust lo reenvía en
|
||||||
|
`ls-tabs` (`dark`) y este documento se pone la clase `oscuro` o `claro`.
|
||||||
|
El bloque de medios queda SOLO como arranque en frío (primer arranque, sin
|
||||||
|
estado.json y sin reporte aún): en cuanto hay clase, la clase manda.
|
||||||
|
OJO: los valores oscuros van DOS veces (media query y .oscuro) — cambiarlos a la par. */
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root:not(.claro) {
|
||||||
--bg: #202124; /* franja (Chrome oscuro) */
|
--bg: #0d0d0f; /* franja: negra, más oscura que el contenido */
|
||||||
--fg: #bdc1c6;
|
--fg: #bdc1c6;
|
||||||
--muted: #80868b;
|
--muted: #80868b;
|
||||||
--tab-active-bg: #18181b; /* mismo fondo que la app → pestaña fundida con el contenido */
|
--tab-active-bg: #18181b; /* mismo fondo que la app → pestaña fundida con el contenido */
|
||||||
--tab-active-fg: #e8eaed;
|
--tab-active-fg: #e8eaed;
|
||||||
--border: #101013;
|
--border: #26262a;
|
||||||
--hover: rgba(255, 255, 255, 0.08);
|
--hover: rgba(255, 255, 255, 0.08);
|
||||||
--btn-hover: rgba(255, 255, 255, 0.1);
|
--btn-hover: rgba(255, 255, 255, 0.1);
|
||||||
--sep: rgba(255, 255, 255, 0.25);
|
--sep: rgba(255, 255, 255, 0.25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
:root.oscuro {
|
||||||
|
--bg: #0d0d0f;
|
||||||
|
--fg: #bdc1c6;
|
||||||
|
--muted: #80868b;
|
||||||
|
--tab-active-bg: #18181b;
|
||||||
|
--tab-active-fg: #e8eaed;
|
||||||
|
--border: #26262a;
|
||||||
|
--hover: rgba(255, 255, 255, 0.08);
|
||||||
|
--btn-hover: rgba(255, 255, 255, 0.1);
|
||||||
|
--sep: rgba(255, 255, 255, 0.25);
|
||||||
|
}
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
html, body {
|
html, body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -59,6 +91,8 @@
|
|||||||
padding: 0 6px 0 8px;
|
padding: 0 6px 0 8px;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
/* macOS: hueco para los botones rojo/amarillo/verde, que son NATIVOS y se pintan encima. */
|
||||||
|
body.mac #bar { padding-left: 78px; }
|
||||||
#tabs {
|
#tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
@@ -69,16 +103,19 @@
|
|||||||
align-self: stretch;
|
align-self: stretch;
|
||||||
margin-bottom: -1px;
|
margin-bottom: -1px;
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
overflow-x: auto;
|
overflow: hidden;
|
||||||
scrollbar-width: none;
|
|
||||||
}
|
}
|
||||||
#tabs::-webkit-scrollbar { display: none; }
|
|
||||||
.tab {
|
.tab {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 7px;
|
gap: 7px;
|
||||||
flex: 0 1 220px;
|
/* Elástico como en Chrome: se reparten el ancho y se encogen al abrir más. El tope
|
||||||
min-width: 100px;
|
sube a 280 px porque los títulos ahora traen nombre real y sección
|
||||||
|
(«Hotjamin Orgánicos · Archivos»), y a 240 se cortaban de más. Con muchas pestañas
|
||||||
|
abiertas da igual: mandan el reparto y el modo compacto. */
|
||||||
|
flex: 1 1 220px;
|
||||||
|
min-width: 42px;
|
||||||
|
max-width: 280px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
padding: 0 6px 0 10px;
|
padding: 0 6px 0 10px;
|
||||||
@@ -129,11 +166,59 @@
|
|||||||
right: -8px;
|
right: -8px;
|
||||||
background: radial-gradient(circle at 8px 0, transparent 8px, var(--tab-active-bg) 8.5px);
|
background: radial-gradient(circle at 8px 0, transparent 8px, var(--tab-active-bg) 8.5px);
|
||||||
}
|
}
|
||||||
|
/* ── Color de pestaña ────────────────────────────────────────────────────────────
|
||||||
|
Misma idea que los grupos de Chrome: teñir para agrupar de un vistazo («todo lo de
|
||||||
|
este cliente, en verde»). El color se elige con clic derecho sobre la pestaña ▸ Color,
|
||||||
|
y se guarda con la sesión.
|
||||||
|
Va en componentes RGB sueltos (`--tc: r, g, b`) para sacar de UNA sola definición
|
||||||
|
tanto el tono sólido como el fondo translúcido, sin repetir nueve colores por tema.
|
||||||
|
La pestaña ACTIVA no se tiñe entera: tiene que seguir fundida con el contenido, así
|
||||||
|
que lleva el color en una franja superior — igual que Chrome. */
|
||||||
|
.tab[data-color="gris"] { --tc: 95, 99, 104; }
|
||||||
|
.tab[data-color="azul"] { --tc: 26, 115, 232; }
|
||||||
|
.tab[data-color="rojo"] { --tc: 217, 48, 37; }
|
||||||
|
.tab[data-color="amarillo"] { --tc: 249, 171, 0; }
|
||||||
|
.tab[data-color="verde"] { --tc: 30, 142, 62; }
|
||||||
|
.tab[data-color="rosa"] { --tc: 208, 24, 132; }
|
||||||
|
.tab[data-color="morado"] { --tc: 147, 52, 230; }
|
||||||
|
.tab[data-color="cian"] { --tc: 0, 123, 131; }
|
||||||
|
.tab[data-color="naranja"] { --tc: 250, 144, 62; }
|
||||||
|
.tab[data-color]:not(.active) { background: rgba(var(--tc), 0.18); }
|
||||||
|
.tab[data-color]:not(.active):hover { background: rgba(var(--tc), 0.32); }
|
||||||
|
/* Con fondo propio el separador vertical sobra: ya se ve dónde acaba cada pestaña. */
|
||||||
|
.tab[data-color]:not(.active)::before { display: none; }
|
||||||
|
.tab[data-color].active { box-shadow: inset 0 3px 0 rgb(var(--tc)); }
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not(.claro) .tab[data-color]:not(.active) { background: rgba(var(--tc), 0.36); }
|
||||||
|
:root:not(.claro) .tab[data-color]:not(.active):hover { background: rgba(var(--tc), 0.5); }
|
||||||
|
}
|
||||||
|
:root.oscuro .tab[data-color]:not(.active) { background: rgba(var(--tc), 0.36); }
|
||||||
|
:root.oscuro .tab[data-color]:not(.active):hover { background: rgba(var(--tc), 0.5); }
|
||||||
|
/* Reordenar arrastrando: NO se usa drag&drop de HTML5 (en el webview de la barra en
|
||||||
|
macOS los eventos no llegan), sino eventos de puntero. Se apaga el arrastre nativo de
|
||||||
|
WebKit para que no salga la imagen fantasma al mover una pestaña. */
|
||||||
|
.tab { -webkit-user-drag: none; }
|
||||||
|
.tab.arrastrando { opacity: 0.5; }
|
||||||
.tab .favicon {
|
.tab .favicon {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
width: 14px;
|
width: 15px;
|
||||||
height: 14px;
|
height: 15px;
|
||||||
border-radius: 3px;
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
font-size: 12.5px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
/* Señal de carga: el icono se sustituye por un aro girando. */
|
||||||
|
.tab .favicon.cargando {
|
||||||
|
border: 1.6px solid var(--sep);
|
||||||
|
border-top-color: var(--accent);
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: giro 0.7s linear infinite;
|
||||||
|
font-size: 0;
|
||||||
|
}
|
||||||
|
@keyframes giro { to { transform: rotate(360deg); } }
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.tab .favicon.cargando { animation-duration: 2.4s; }
|
||||||
}
|
}
|
||||||
.tab .titulo {
|
.tab .titulo {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
@@ -156,6 +241,11 @@
|
|||||||
}
|
}
|
||||||
.tab:hover .cerrar, .tab.active .cerrar { visibility: visible; }
|
.tab:hover .cerrar, .tab.active .cerrar { visibility: visible; }
|
||||||
.tab .cerrar:hover { background: var(--btn-hover); color: var(--tab-active-fg); }
|
.tab .cerrar:hover { background: var(--btn-hover); color: var(--tab-active-fg); }
|
||||||
|
/* Muchas pestañas abiertas: solo el icono (el nombre completo queda en el tooltip),
|
||||||
|
y la × únicamente en la activa — como hace Chrome al quedarse sin sitio. */
|
||||||
|
#tabs.compactas .tab { padding: 0 6px; justify-content: center; }
|
||||||
|
#tabs.compactas .tab .titulo { display: none; }
|
||||||
|
#tabs.compactas .tab:not(.active) .cerrar { display: none; }
|
||||||
button {
|
button {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
border: 0;
|
border: 0;
|
||||||
@@ -171,7 +261,7 @@
|
|||||||
.icono {
|
.icono {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
margin: 2px 0 7px;
|
height: 26px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
#zoom {
|
#zoom {
|
||||||
@@ -179,35 +269,63 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1px;
|
gap: 1px;
|
||||||
margin: 2px 0 7px;
|
|
||||||
}
|
}
|
||||||
#zoom button { height: 100%; }
|
#z-menos, #z-mas { width: 26px; height: 26px; font-size: 14px; }
|
||||||
#z-menos, #z-mas { width: 26px; font-size: 14px; }
|
|
||||||
#z-pct {
|
#z-pct {
|
||||||
min-width: 44px;
|
min-width: 44px;
|
||||||
|
height: 26px;
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: 11.5px;
|
font-size: 11.5px;
|
||||||
|
border-radius: 13px;
|
||||||
}
|
}
|
||||||
#z-pct.activo { color: var(--accent); font-weight: 600; }
|
#z-pct.activo { color: var(--accent); font-weight: 600; }
|
||||||
#version {
|
#version {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
margin: 2px 0 7px;
|
height: 26px;
|
||||||
padding: 0 7px;
|
padding: 0 7px;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
border-radius: 13px;
|
||||||
}
|
}
|
||||||
#version:hover { color: var(--accent); }
|
#version:hover { color: var(--accent); }
|
||||||
|
/* ── Botones de ventana ──────────────────────────────────────────────────────────
|
||||||
|
Solo en Windows: allí la ventana va SIN decoración, así que esta barra es la fila
|
||||||
|
del título (como Chrome) y el aspa del sistema no existe. Medidas y colores del
|
||||||
|
propio Windows 11: 46 px de ancho, alto completo de la barra, esquinas rectas
|
||||||
|
hasta el borde, y rojo #c42b1c en el aspa al pasar por encima.
|
||||||
|
Los glifos salen de la fuente de iconos del sistema (Fluent en Win 11, MDL2 en 10). */
|
||||||
|
#wincontrols { display: none; }
|
||||||
|
body.win #wincontrols {
|
||||||
|
display: flex;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
align-self: stretch;
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
/* Los botones tienen que morder el borde derecho: la barra cede su margen. */
|
||||||
|
body.win #bar { padding-right: 0; }
|
||||||
|
#wincontrols button {
|
||||||
|
width: 46px;
|
||||||
|
border-radius: 0;
|
||||||
|
color: var(--fg);
|
||||||
|
font-family: "Segoe Fluent Icons", "Segoe MDL2 Assets", system-ui;
|
||||||
|
font-size: 10px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
#wincontrols button:hover { background: var(--btn-hover); }
|
||||||
|
#w-cerrar:hover { background: #c42b1c; color: #fff; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="bar">
|
<!-- data-tauri-drag-region: el hueco libre de la barra mueve la ventana y el doble clic
|
||||||
|
la maximiza (en macOS ya no hay barra de título nativa de la que tirar). -->
|
||||||
|
<div id="bar" data-tauri-drag-region>
|
||||||
<button class="icono" id="atras" title="Atrás (⌘/Ctrl+[)">←</button>
|
<button class="icono" id="atras" title="Atrás (⌘/Ctrl+[)">←</button>
|
||||||
<button class="icono" id="adelante" title="Adelante (⌘/Ctrl+])">→</button>
|
<button class="icono" id="adelante" title="Adelante (⌘/Ctrl+])">→</button>
|
||||||
<div id="tabs" title=""></div>
|
<div id="tabs" data-tauri-drag-region></div>
|
||||||
<button class="icono" id="nueva" title="Nueva pestaña (⌘/Ctrl+T)">+</button>
|
<button class="icono" id="nueva" title="Nueva pestaña (⌘/Ctrl+T)">+</button>
|
||||||
<button class="icono" id="recargar" title="Recargar (⌘/Ctrl+R)">⟳</button>
|
<button class="icono" id="recargar" title="Recargar (⌘/Ctrl+R)">⟳</button>
|
||||||
<div id="zoom">
|
<div id="zoom">
|
||||||
@@ -217,6 +335,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<button id="version" title="Versión de la app · clic: buscar actualización"></button>
|
<button id="version" title="Versión de la app · clic: buscar actualización"></button>
|
||||||
<button class="icono" id="menu" title="Opciones de la app">⋮</button>
|
<button class="icono" id="menu" title="Opciones de la app">⋮</button>
|
||||||
|
<!-- Solo visibles en Windows (clase `win` del body): allí no hay barra de título. -->
|
||||||
|
<div id="wincontrols">
|
||||||
|
<button id="w-min" title="Minimizar"></button>
|
||||||
|
<button id="w-max" title="Maximizar"></button>
|
||||||
|
<button id="w-cerrar" title="Cerrar"></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
const T = window.__TAURI__;
|
const T = window.__TAURI__;
|
||||||
@@ -230,32 +354,139 @@
|
|||||||
const $tabs = document.getElementById("tabs");
|
const $tabs = document.getElementById("tabs");
|
||||||
const $pct = document.getElementById("z-pct");
|
const $pct = document.getElementById("z-pct");
|
||||||
const $ver = document.getElementById("version");
|
const $ver = document.getElementById("version");
|
||||||
|
const $wmax = document.getElementById("w-max");
|
||||||
|
|
||||||
// Favicon de las pestañas (look Chrome): mini logo Labstream en SVG inline —
|
// Nombre + icono de cada pestaña a partir de su RUTA (mismas etiquetas que la barra
|
||||||
// cuadrado indigo con la "L" — para no depender de archivos ni de la red.
|
// superior de la web). Sin esto todas las pestañas se llamaban «(25) Labstream OS» y
|
||||||
const FAVICON = "data:image/svg+xml," + encodeURIComponent(
|
// no había forma de distinguirlas.
|
||||||
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>" +
|
const RUTAS = [
|
||||||
"<rect width='16' height='16' rx='4' fill='#6366f1'/>" +
|
[/^\/$/, "🏠", "Inicio"],
|
||||||
"<path d='M5.2 3.8v7h5.6' stroke='#fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' fill='none'/>" +
|
[/^\/inicio/, "🏠", "Inicio"],
|
||||||
"</svg>",
|
[/^\/mis-tareas/, "✅", "Mis tareas"],
|
||||||
);
|
[/^\/mis-entregas/, "📦", "Mis entregas"],
|
||||||
|
[/^\/estados/, "💬", "Chat del día"],
|
||||||
|
[/^\/chat/, "💬", "Chats"],
|
||||||
|
[/^\/notas/, "📝", "Notas"],
|
||||||
|
[/^\/recordatorios/, "⏰", "Recordatorios"],
|
||||||
|
[/^\/proyectos\/nuevo/, "✨", "Nuevo proyecto"],
|
||||||
|
[/^\/proyectos\/[^/]+/, "🎬", "Proyecto"],
|
||||||
|
[/^\/proyectos/, "🎬", "Proyectos"],
|
||||||
|
[/^\/plantillas/, "🗂️", "Plantillas"],
|
||||||
|
[/^\/calendario/, "📅", "Calendario"],
|
||||||
|
[/^\/wiki\/inventario/, "📦", "Inventario"],
|
||||||
|
[/^\/wiki\/ubicacion/, "📍", "Ubicación"],
|
||||||
|
[/^\/wiki/, "📚", "Wiki"],
|
||||||
|
[/^\/clientes\/nuevo/, "✨", "Nuevo cliente"],
|
||||||
|
[/^\/clientes\/[^/]+/, "👤", "Cliente"],
|
||||||
|
[/^\/clientes/, "👤", "Clientes"],
|
||||||
|
[/^\/operaciones/, "🗄️", "Operaciones"],
|
||||||
|
[/^\/revisiones/, "🎞️", "Revisiones"],
|
||||||
|
[/^\/entregas-finales/, "🏁", "Entregas finales"],
|
||||||
|
[/^\/cotizaciones/, "🧾", "Cotizaciones"],
|
||||||
|
[/^\/propuestas/, "📄", "Propuestas"],
|
||||||
|
[/^\/facturacion/, "💵", "Facturación"],
|
||||||
|
[/^\/comercial/, "📈", "Comercial"],
|
||||||
|
[/^\/biblioteca/, "📚", "Biblioteca"],
|
||||||
|
[/^\/reportes/, "📊", "Reportes"],
|
||||||
|
[/^\/timeline/, "🧭", "Cronograma"],
|
||||||
|
[/^\/asistente/, "🤖", "Marcebot"],
|
||||||
|
[/^\/configuracion/, "⚙️", "Configuración"],
|
||||||
|
[/^\/ajustes/, "⚙️", "Ajustes"],
|
||||||
|
[/^\/perfil/, "👤", "Mi perfil"],
|
||||||
|
[/^\/papelera/, "🗑️", "Papelera"],
|
||||||
|
[/^\/docs\//, "📄", "Documento"],
|
||||||
|
];
|
||||||
|
|
||||||
|
function rutaMeta(url) {
|
||||||
|
let ruta = "/";
|
||||||
|
try { ruta = new URL(url).pathname; } catch (e) {}
|
||||||
|
for (const [re, emoji, nombre] of RUTAS) {
|
||||||
|
if (re.test(ruta)) return { emoji, nombre };
|
||||||
|
}
|
||||||
|
return { emoji: "🗂️", nombre: "Labstream OS" };
|
||||||
|
}
|
||||||
|
|
||||||
|
// El título de la web es «(25) Labstream OS» en todas las páginas: se le quita el
|
||||||
|
// contador de no leídos y el nombre de la app. Si queda algo propio, ese manda (así,
|
||||||
|
// el día que la web ponga títulos por página, la barra los aprovecha sola).
|
||||||
|
function limpiarTitulo(t) {
|
||||||
|
if (!t) return "";
|
||||||
|
let x = String(t).replace(/^\(\d+\)\s*/, "").trim();
|
||||||
|
x = x.replace(/\s*[·|—–-]\s*Labstream(\s+OS)?\s*$/i, "").trim();
|
||||||
|
return /^labstream(\s+os)?$/i.test(x) ? "" : x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nombreDe(t) {
|
||||||
|
const meta = rutaMeta(t.url || "");
|
||||||
|
return { emoji: meta.emoji, texto: limpiarTitulo(t.title) || meta.nombre };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reordenar arrastrando, con eventos de PUNTERO: el drag&drop de HTML5 no llega al
|
||||||
|
// webview de la barra en macOS. Se mueve el nodo en vivo y al soltar se manda el orden.
|
||||||
|
let arrastre = null; // {el, x0, movido}
|
||||||
|
let tragarClick = false; // el clic que cierra el arrastre no debe activar la pestaña
|
||||||
|
|
||||||
|
function ordenActual() {
|
||||||
|
return Array.from($tabs.children).map((el) => el.dataset.label);
|
||||||
|
}
|
||||||
|
|
||||||
|
addEventListener("mousemove", (e) => {
|
||||||
|
if (!arrastre) return;
|
||||||
|
if (!arrastre.movido) {
|
||||||
|
if (Math.abs(e.clientX - arrastre.x0) < 5) return; // todavía es un clic, no un arrastre
|
||||||
|
arrastre.movido = true;
|
||||||
|
arrastre.el.classList.add("arrastrando");
|
||||||
|
}
|
||||||
|
for (const otro of Array.from($tabs.children)) {
|
||||||
|
if (otro === arrastre.el) continue;
|
||||||
|
const r = otro.getBoundingClientRect();
|
||||||
|
if (e.clientX >= r.left && e.clientX <= r.right) {
|
||||||
|
const despues = e.clientX > r.left + r.width / 2;
|
||||||
|
$tabs.insertBefore(arrastre.el, despues ? otro.nextSibling : otro);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addEventListener("mouseup", () => {
|
||||||
|
if (!arrastre) return;
|
||||||
|
const { el, movido } = arrastre;
|
||||||
|
arrastre = null;
|
||||||
|
el.classList.remove("arrastrando");
|
||||||
|
if (movido) {
|
||||||
|
tragarClick = true;
|
||||||
|
emitir("ls-reorder", { order: ordenActual().join(",") });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Modo solo-icono: se mide el ancho REAL de una pestaña ya pintada (el reparto lo hace
|
||||||
|
// flex, así que todas miden igual) en vez de estimarlo dividiendo el contenedor.
|
||||||
|
function ajustarCompactas() {
|
||||||
|
const primera = $tabs.firstElementChild;
|
||||||
|
if (!primera) return;
|
||||||
|
const ancho = primera.getBoundingClientRect().width;
|
||||||
|
if (!ancho) return;
|
||||||
|
$tabs.classList.toggle("compactas", ancho < 112);
|
||||||
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
$tabs.textContent = "";
|
$tabs.textContent = "";
|
||||||
for (const t of estado.tabs) {
|
for (const t of estado.tabs) {
|
||||||
|
const { emoji, texto } = nombreDe(t);
|
||||||
const el = document.createElement("div");
|
const el = document.createElement("div");
|
||||||
el.className = "tab" + (t.active ? " active" : "");
|
el.className = "tab" + (t.active ? " active" : "");
|
||||||
el.title = t.title;
|
el.dataset.label = t.label;
|
||||||
|
if (t.color) el.dataset.color = t.color; // teñido desde el menú de la pestaña
|
||||||
|
el.title = texto;
|
||||||
|
|
||||||
const fav = document.createElement("img");
|
const fav = document.createElement("span");
|
||||||
fav.className = "favicon";
|
fav.className = "favicon" + (t.loading ? " cargando" : "");
|
||||||
fav.src = FAVICON;
|
fav.textContent = t.loading ? "" : emoji;
|
||||||
fav.alt = "";
|
|
||||||
el.appendChild(fav);
|
el.appendChild(fav);
|
||||||
|
|
||||||
const titulo = document.createElement("span");
|
const titulo = document.createElement("span");
|
||||||
titulo.className = "titulo";
|
titulo.className = "titulo";
|
||||||
titulo.textContent = t.title || "Labstream OS";
|
titulo.textContent = texto;
|
||||||
el.appendChild(titulo);
|
el.appendChild(titulo);
|
||||||
|
|
||||||
const x = document.createElement("button");
|
const x = document.createElement("button");
|
||||||
@@ -268,19 +499,54 @@
|
|||||||
});
|
});
|
||||||
el.appendChild(x);
|
el.appendChild(x);
|
||||||
|
|
||||||
el.addEventListener("click", () => emitir("ls-activate", { label: t.label }));
|
el.addEventListener("click", () => {
|
||||||
|
if (tragarClick) { tragarClick = false; return; } // veníamos de reordenar
|
||||||
|
emitir("ls-activate", { label: t.label });
|
||||||
|
});
|
||||||
// Clic central sobre la pestaña = cerrarla (como en el navegador).
|
// Clic central sobre la pestaña = cerrarla (como en el navegador).
|
||||||
el.addEventListener("auxclick", (e) => {
|
el.addEventListener("auxclick", (e) => {
|
||||||
if (e.button === 1) emitir("ls-close-tab", { label: t.label });
|
if (e.button === 1) emitir("ls-close-tab", { label: t.label });
|
||||||
});
|
});
|
||||||
|
// Clic derecho: menú NATIVO de la pestaña (duplicar, cerrar otras, copiar enlace…).
|
||||||
|
// La barra mide 40px: un menú dibujado aquí dentro quedaría recortado.
|
||||||
|
el.addEventListener("contextmenu", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
emitir("ls-tab-menu", { label: t.label });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reordenar arrastrando: lo gestionan los listeners de puntero de más arriba.
|
||||||
|
el.addEventListener("mousedown", (e) => {
|
||||||
|
if (e.button !== 0) return;
|
||||||
|
arrastre = { el, x0: e.clientX, movido: false };
|
||||||
|
});
|
||||||
|
|
||||||
$tabs.appendChild(el);
|
$tabs.appendChild(el);
|
||||||
}
|
}
|
||||||
|
requestAnimationFrame(ajustarCompactas);
|
||||||
|
|
||||||
const activa = $tabs.querySelector(".tab.active");
|
const activa = $tabs.querySelector(".tab.active");
|
||||||
if (activa) activa.scrollIntoView({ block: "nearest", inline: "nearest" });
|
if (activa) activa.scrollIntoView({ block: "nearest", inline: "nearest" });
|
||||||
|
|
||||||
$pct.textContent = estado.zoom + "%";
|
$pct.textContent = estado.zoom + "%";
|
||||||
$pct.classList.toggle("activo", estado.zoom !== 100);
|
$pct.classList.toggle("activo", estado.zoom !== 100);
|
||||||
$ver.textContent = estado.version ? "v" + estado.version : "";
|
$ver.textContent = estado.version ? "v" + estado.version : "";
|
||||||
|
// Tema: manda el de la APP (payload `dark`). Mientras Rust no sepa nada (null),
|
||||||
|
// no se pone clase y siguen las media queries del sistema como arranque en frío.
|
||||||
|
if (typeof estado.dark === "boolean") {
|
||||||
|
document.documentElement.classList.toggle("oscuro", estado.dark);
|
||||||
|
document.documentElement.classList.toggle("claro", !estado.dark);
|
||||||
|
}
|
||||||
|
// En macOS la barra ES la fila del título: hay que dejar libre el semáforo.
|
||||||
|
document.body.classList.toggle("mac", !!estado.mac);
|
||||||
|
// En Windows también ES la fila del título, pero ahí los botones de ventana los
|
||||||
|
// pinta esta barra: el del medio alterna entre maximizar (▢) y restaurar (❐).
|
||||||
|
document.body.classList.toggle("win", !!estado.win);
|
||||||
|
if (estado.win) {
|
||||||
|
const max = !!estado.maximized;
|
||||||
|
$wmax.textContent = max ? "\uE923" : "\uE922"; // ChromeRestore / ChromeMaximize
|
||||||
|
$wmax.title = max ? "Restaurar" : "Maximizar";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (E) {
|
if (E) {
|
||||||
@@ -289,6 +555,8 @@
|
|||||||
render();
|
render();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Al cambiar el ancho de la ventana se recalcula si caben los nombres.
|
||||||
|
addEventListener("resize", ajustarCompactas);
|
||||||
|
|
||||||
document.getElementById("atras").addEventListener("click", () => emitir("ls-nav", { dir: -1 }));
|
document.getElementById("atras").addEventListener("click", () => emitir("ls-nav", { dir: -1 }));
|
||||||
document.getElementById("adelante").addEventListener("click", () => emitir("ls-nav", { dir: 1 }));
|
document.getElementById("adelante").addEventListener("click", () => emitir("ls-nav", { dir: 1 }));
|
||||||
@@ -304,10 +572,14 @@
|
|||||||
document.getElementById("z-menos").addEventListener("click", () => emitir("ls-zoom", { dir: -1 }));
|
document.getElementById("z-menos").addEventListener("click", () => emitir("ls-zoom", { dir: -1 }));
|
||||||
document.getElementById("z-mas").addEventListener("click", () => emitir("ls-zoom", { dir: 1 }));
|
document.getElementById("z-mas").addEventListener("click", () => emitir("ls-zoom", { dir: 1 }));
|
||||||
$pct.addEventListener("click", () => emitir("ls-zoom", { dir: 0 }));
|
$pct.addEventListener("click", () => emitir("ls-zoom", { dir: 0 }));
|
||||||
// Doble clic en el hueco libre de la barra = pestaña nueva.
|
// Botones de ventana (Windows). Cerrar oculta a la bandeja, como el aspa de siempre.
|
||||||
$tabs.addEventListener("dblclick", (e) => {
|
document.getElementById("w-min").addEventListener("click", () => emitir("ls-window", { act: "min" }));
|
||||||
if (e.target === $tabs) emitir("ls-new-tab", {});
|
$wmax.addEventListener("click", () => emitir("ls-window", { act: "max" }));
|
||||||
});
|
document.getElementById("w-cerrar").addEventListener("click", () => emitir("ls-window", { act: "close" }));
|
||||||
|
// El doble clic en el hueco libre lo gobierna `data-tauri-drag-region`: maximiza y
|
||||||
|
// restaura, como la barra de título del sistema y como la de pestañas de Chrome.
|
||||||
|
// (Antes abría una pestaña nueva; ahora que la barra ES el título, chocaba con él.
|
||||||
|
// Para una pestaña nueva quedan el botón + y ⌘/Ctrl+T.)
|
||||||
|
|
||||||
// Atajos también cuando el foco está en la barra.
|
// Atajos también cuando el foco está en la barra.
|
||||||
addEventListener("keydown", (e) => {
|
addEventListener("keydown", (e) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "labstream-desktop",
|
"name": "labstream-desktop",
|
||||||
"version": "1.4.0",
|
"version": "1.8.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "App de escritorio (Windows) que envuelve Labstream OS — cliente del servidor del NAS.",
|
"description": "App de escritorio (Windows) que envuelve Labstream OS — cliente del servidor del NAS.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
351
src-tauri/Cargo.lock
generado
351
src-tauri/Cargo.lock
generado
@@ -56,6 +56,27 @@ dependencies = [
|
|||||||
"derive_arbitrary",
|
"derive_arbitrary",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arboard"
|
||||||
|
version = "3.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf"
|
||||||
|
dependencies = [
|
||||||
|
"clipboard-win",
|
||||||
|
"image",
|
||||||
|
"log",
|
||||||
|
"objc2",
|
||||||
|
"objc2-app-kit",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
"objc2-core-graphics",
|
||||||
|
"objc2-foundation",
|
||||||
|
"parking_lot",
|
||||||
|
"percent-encoding",
|
||||||
|
"windows-sys 0.60.2",
|
||||||
|
"wl-clipboard-rs",
|
||||||
|
"x11rb",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-broadcast"
|
name = "async-broadcast"
|
||||||
version = "0.7.2"
|
version = "0.7.2"
|
||||||
@@ -354,6 +375,12 @@ version = "1.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder-lite"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.12.0"
|
version = "1.12.0"
|
||||||
@@ -485,6 +512,15 @@ dependencies = [
|
|||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clipboard-win"
|
||||||
|
version = "5.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4"
|
||||||
|
dependencies = [
|
||||||
|
"error-code",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "combine"
|
name = "combine"
|
||||||
version = "4.6.7"
|
version = "4.6.7"
|
||||||
@@ -587,6 +623,12 @@ version = "0.8.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crunchy"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
@@ -827,13 +869,19 @@ checksum = "521e380c0c8afb8d9a1e83a1822ee03556fc3e3e7dbc1fd30be14e37f9cb3f89"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-set",
|
"bit-set",
|
||||||
"cssparser",
|
"cssparser",
|
||||||
"foldhash",
|
"foldhash 0.2.0",
|
||||||
"html5ever",
|
"html5ever",
|
||||||
"precomputed-hash",
|
"precomputed-hash",
|
||||||
"selectors",
|
"selectors",
|
||||||
"tendril",
|
"tendril",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "downcast-rs"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dpi"
|
name = "dpi"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
@@ -959,6 +1007,12 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "error-code"
|
||||||
|
version = "3.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "event-listener"
|
name = "event-listener"
|
||||||
version = "5.4.1"
|
version = "5.4.1"
|
||||||
@@ -986,6 +1040,12 @@ version = "2.4.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
|
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fax"
|
||||||
|
version = "0.2.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fdeflate"
|
name = "fdeflate"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
@@ -1021,6 +1081,12 @@ version = "0.1.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fixedbitset"
|
||||||
|
version = "0.5.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.1.9"
|
version = "1.1.9"
|
||||||
@@ -1037,6 +1103,12 @@ version = "1.0.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "foldhash"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foldhash"
|
name = "foldhash"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -1272,6 +1344,16 @@ dependencies = [
|
|||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gethostname"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
|
||||||
|
dependencies = [
|
||||||
|
"rustix",
|
||||||
|
"windows-link 0.2.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@@ -1454,12 +1536,32 @@ dependencies = [
|
|||||||
"syn 2.0.118",
|
"syn 2.0.118",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "half"
|
||||||
|
version = "2.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crunchy",
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.15.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||||
|
dependencies = [
|
||||||
|
"foldhash 0.1.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.17.1"
|
version = "0.17.1"
|
||||||
@@ -1740,6 +1842,20 @@ dependencies = [
|
|||||||
"icu_properties",
|
"icu_properties",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "image"
|
||||||
|
version = "0.25.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"
|
||||||
|
dependencies = [
|
||||||
|
"bytemuck",
|
||||||
|
"byteorder-lite",
|
||||||
|
"moxcms",
|
||||||
|
"num-traits",
|
||||||
|
"png 0.18.1",
|
||||||
|
"tiff",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.9.3"
|
version = "1.9.3"
|
||||||
@@ -1946,13 +2062,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "labstream-desktop"
|
name = "labstream-desktop"
|
||||||
version = "1.4.2"
|
version = "1.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tauri",
|
"tauri",
|
||||||
"tauri-build",
|
"tauri-build",
|
||||||
"tauri-plugin-autostart",
|
"tauri-plugin-autostart",
|
||||||
|
"tauri-plugin-clipboard-manager",
|
||||||
"tauri-plugin-notification",
|
"tauri-plugin-notification",
|
||||||
"tauri-plugin-opener",
|
"tauri-plugin-opener",
|
||||||
"tauri-plugin-single-instance",
|
"tauri-plugin-single-instance",
|
||||||
@@ -2117,6 +2234,16 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "moxcms"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"pxfm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "muda"
|
name = "muda"
|
||||||
version = "0.19.3"
|
version = "0.19.3"
|
||||||
@@ -2168,6 +2295,15 @@ version = "1.0.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "8.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "notify-rust"
|
name = "notify-rust"
|
||||||
version = "4.18.0"
|
version = "4.18.0"
|
||||||
@@ -2239,6 +2375,7 @@ dependencies = [
|
|||||||
"block2",
|
"block2",
|
||||||
"objc2",
|
"objc2",
|
||||||
"objc2-core-foundation",
|
"objc2-core-foundation",
|
||||||
|
"objc2-core-graphics",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2467,6 +2604,16 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "os_pipe"
|
||||||
|
version = "1.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys 0.61.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "osakit"
|
name = "osakit"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -2547,6 +2694,17 @@ version = "2.3.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "petgraph"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455"
|
||||||
|
dependencies = [
|
||||||
|
"fixedbitset",
|
||||||
|
"hashbrown 0.15.5",
|
||||||
|
"indexmap 2.14.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf"
|
name = "phf"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
@@ -2631,7 +2789,7 @@ checksum = "092791278e026273c1b65bbdcfbba3a300f2994c896bd01ab01da613c29c46f1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"indexmap 2.14.0",
|
"indexmap 2.14.0",
|
||||||
"quick-xml",
|
"quick-xml 0.39.4",
|
||||||
"serde",
|
"serde",
|
||||||
"time",
|
"time",
|
||||||
]
|
]
|
||||||
@@ -2768,6 +2926,18 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pxfm"
|
||||||
|
version = "0.1.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick-error"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
version = "0.39.4"
|
version = "0.39.4"
|
||||||
@@ -2777,6 +2947,15 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick-xml"
|
||||||
|
version = "0.41.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.45"
|
version = "1.0.45"
|
||||||
@@ -3801,6 +3980,21 @@ dependencies = [
|
|||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tauri-plugin-clipboard-manager"
|
||||||
|
version = "2.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "206dc20af4ed210748ba945c2774e60fd0acd52b9a73a028402caf809e9b6ecf"
|
||||||
|
dependencies = [
|
||||||
|
"arboard",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tauri",
|
||||||
|
"tauri-plugin",
|
||||||
|
"thiserror 2.0.18",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-plugin-notification"
|
name = "tauri-plugin-notification"
|
||||||
version = "2.3.3"
|
version = "2.3.3"
|
||||||
@@ -4065,6 +4259,20 @@ dependencies = [
|
|||||||
"syn 2.0.118",
|
"syn 2.0.118",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tiff"
|
||||||
|
version = "0.11.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52"
|
||||||
|
dependencies = [
|
||||||
|
"fax",
|
||||||
|
"flate2",
|
||||||
|
"half",
|
||||||
|
"quick-error",
|
||||||
|
"weezl",
|
||||||
|
"zune-jpeg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.49"
|
version = "0.3.49"
|
||||||
@@ -4375,6 +4583,17 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tree_magic_mini"
|
||||||
|
version = "3.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"nom",
|
||||||
|
"petgraph",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "try-lock"
|
name = "try-lock"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
@@ -4646,6 +4865,76 @@ dependencies = [
|
|||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wayland-backend"
|
||||||
|
version = "0.3.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "016ccf01d1c58b6f8999612813e17c9b2390f7d70671428869913310f83f54b8"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"downcast-rs",
|
||||||
|
"rustix",
|
||||||
|
"smallvec",
|
||||||
|
"wayland-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wayland-client"
|
||||||
|
version = "0.31.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.13.0",
|
||||||
|
"rustix",
|
||||||
|
"wayland-backend",
|
||||||
|
"wayland-scanner",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wayland-protocols"
|
||||||
|
version = "0.32.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.13.0",
|
||||||
|
"wayland-backend",
|
||||||
|
"wayland-client",
|
||||||
|
"wayland-scanner",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wayland-protocols-wlr"
|
||||||
|
version = "0.3.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.13.0",
|
||||||
|
"wayland-backend",
|
||||||
|
"wayland-client",
|
||||||
|
"wayland-protocols",
|
||||||
|
"wayland-scanner",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wayland-scanner"
|
||||||
|
version = "0.31.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quick-xml 0.41.0",
|
||||||
|
"quote",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wayland-sys"
|
||||||
|
version = "0.31.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be"
|
||||||
|
dependencies = [
|
||||||
|
"pkg-config",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.102"
|
version = "0.3.102"
|
||||||
@@ -4757,6 +5046,12 @@ dependencies = [
|
|||||||
"windows-core 0.61.2",
|
"windows-core 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "weezl"
|
||||||
|
version = "0.1.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -5240,6 +5535,24 @@ version = "0.57.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wl-clipboard-rs"
|
||||||
|
version = "0.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e9651471a32e87d96ef3a127715382b2d11cc7c8bb9822ded8a7cc94072eb0a3"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"os_pipe",
|
||||||
|
"rustix",
|
||||||
|
"thiserror 2.0.18",
|
||||||
|
"tree_magic_mini",
|
||||||
|
"wayland-backend",
|
||||||
|
"wayland-client",
|
||||||
|
"wayland-protocols",
|
||||||
|
"wayland-protocols-wlr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "writeable"
|
name = "writeable"
|
||||||
version = "0.6.3"
|
version = "0.6.3"
|
||||||
@@ -5311,6 +5624,23 @@ dependencies = [
|
|||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "x11rb"
|
||||||
|
version = "0.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414"
|
||||||
|
dependencies = [
|
||||||
|
"gethostname",
|
||||||
|
"rustix",
|
||||||
|
"x11rb-protocol",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "x11rb-protocol"
|
||||||
|
version = "0.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xattr"
|
name = "xattr"
|
||||||
version = "1.6.1"
|
version = "1.6.1"
|
||||||
@@ -5503,6 +5833,21 @@ version = "1.0.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zune-core"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cb8a0807f7c01457d0379ba880ba6322660448ddebc890ce29bb64da71fb40f9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zune-jpeg"
|
||||||
|
version = "0.5.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
|
||||||
|
dependencies = [
|
||||||
|
"zune-core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zvariant"
|
name = "zvariant"
|
||||||
version = "5.12.0"
|
version = "5.12.0"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "labstream-desktop"
|
name = "labstream-desktop"
|
||||||
version = "1.4.2"
|
version = "1.8.0"
|
||||||
description = "Cliente de escritorio de Labstream OS"
|
description = "Cliente de escritorio de Labstream OS"
|
||||||
authors = ["Labstream SAS"]
|
authors = ["Labstream SAS"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -15,11 +15,25 @@ tauri-build = { version = "2", features = [] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# `unstable` habilita multiwebview: varios webviews (pestañas) dentro de UNA ventana.
|
# `unstable` habilita multiwebview: varios webviews (pestañas) dentro de UNA ventana.
|
||||||
tauri = { version = "2", features = ["tray-icon", "unstable"] }
|
# `devtools` deja el inspector disponible TAMBIÉN en release (por defecto solo va en debug:
|
||||||
|
# wry-0.55.1/src/lib.rs:834-837). Sin él, un fallo que solo aparece en la app instalada —como
|
||||||
|
# el de OnlyOffice en Windows— no se puede mirar por dentro y hay que deducirlo leyendo
|
||||||
|
# fuentes. Con él, clic derecho → Inspeccionar sobre el marco que falle y se acabó.
|
||||||
|
tauri = { version = "2", features = ["tray-icon", "unstable", "devtools"] }
|
||||||
tauri-plugin-opener = "2"
|
tauri-plugin-opener = "2"
|
||||||
|
tauri-plugin-clipboard-manager = "2"
|
||||||
tauri-plugin-notification = "2"
|
tauri-plugin-notification = "2"
|
||||||
tauri-plugin-autostart = "2"
|
tauri-plugin-autostart = "2"
|
||||||
tauri-plugin-updater = "2"
|
tauri-plugin-updater = "2"
|
||||||
tauri-plugin-single-instance = "2"
|
tauri-plugin-single-instance = "2"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
# ── Rastreador de trabajo efectivo (src/tracker.rs) ──
|
||||||
|
# active-win-pos-rs: la ventana al frente (app + título) en Win/Mac.
|
||||||
|
# device_query: ¿hubo entrada? (huella de mouse/teclas presionadas; NUNCA qué se tecleó).
|
||||||
|
# ureq: subir los lotes a /api/tracker (bloqueante, corre en su propio hilo).
|
||||||
|
# gethostname: el nombre del equipo, que bautiza al device en el servidor.
|
||||||
|
active-win-pos-rs = "0.11"
|
||||||
|
device_query = "4"
|
||||||
|
ureq = { version = "2", features = ["json"] }
|
||||||
|
gethostname = "0.5"
|
||||||
|
|||||||
@@ -2,14 +2,22 @@
|
|||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
"identifier": "default",
|
"identifier": "default",
|
||||||
"description": "Permisos del shell de escritorio: la barra local (chrome) y las pestañas remotas (tab-*).",
|
"description": "Permisos del shell de escritorio: la barra local (chrome) y las pestañas remotas (tab-*).",
|
||||||
"windows": ["main"],
|
"windows": [
|
||||||
"webviews": ["chrome", "tab-*"],
|
"main"
|
||||||
|
],
|
||||||
|
"webviews": [
|
||||||
|
"chrome",
|
||||||
|
"tab-*"
|
||||||
|
],
|
||||||
"remote": {
|
"remote": {
|
||||||
"urls": ["https://os.labstreamsas.com"]
|
"urls": [
|
||||||
|
"https://os.labstreamsas.com"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
"opener:default",
|
"opener:default",
|
||||||
"notification:default"
|
"notification:default",
|
||||||
|
"core:window:allow-start-dragging"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
// `core:default` también para el origen remoto (capabilities/default.json). Así no hace falta
|
// `core:default` también para el origen remoto (capabilities/default.json). Así no hace falta
|
||||||
// declarar comandos propios en el ACL para páginas remotas.
|
// declarar comandos propios en el ACL para páginas remotas.
|
||||||
|
|
||||||
|
mod tracker;
|
||||||
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -39,21 +41,21 @@ use serde_json::json;
|
|||||||
use tauri::{
|
use tauri::{
|
||||||
menu::{CheckMenuItem, Menu, MenuItem, PredefinedMenuItem, Submenu},
|
menu::{CheckMenuItem, Menu, MenuItem, PredefinedMenuItem, Submenu},
|
||||||
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
||||||
webview::{PageLoadEvent, Webview, WebviewBuilder},
|
webview::{DownloadEvent, PageLoadEvent, Webview, WebviewBuilder},
|
||||||
window::{Window, WindowBuilder},
|
window::{Window, WindowBuilder},
|
||||||
AppHandle, Emitter, EventTarget, Listener, LogicalPosition, LogicalSize, Manager, Runtime,
|
AppHandle, Emitter, EventTarget, Listener, LogicalPosition, LogicalSize, Manager, Runtime,
|
||||||
Url, WebviewUrl, WindowEvent,
|
Url, WebviewUrl, WindowEvent,
|
||||||
};
|
};
|
||||||
use tauri_plugin_autostart::{MacosLauncher, ManagerExt};
|
use tauri_plugin_autostart::{MacosLauncher, ManagerExt};
|
||||||
use tauri_plugin_notification::NotificationExt;
|
use tauri_plugin_notification::NotificationExt;
|
||||||
|
use tauri_plugin_clipboard_manager::ClipboardExt;
|
||||||
use tauri_plugin_opener::OpenerExt;
|
use tauri_plugin_opener::OpenerExt;
|
||||||
|
|
||||||
const SERVER_URL: &str = "https://os.labstreamsas.com";
|
const SERVER_URL: &str = "https://os.labstreamsas.com";
|
||||||
const TAB_BAR_H: f64 = 40.0; // alto lógico de la barra de pestañas (chrome)
|
const TAB_BAR_H: f64 = 40.0; // alto lógico de la barra de pestañas (chrome)
|
||||||
const CHROME: &str = "chrome";
|
const CHROME: &str = "chrome";
|
||||||
// Alto de la barra de título nativa de macOS (ventana estándar). Ver `top_offset`.
|
// Hueco que ocupan los botones rojo/amarillo/verde en macOS: la barra deja libre ese
|
||||||
#[cfg(target_os = "macos")]
|
// espacio a la izquierda (lo aplica el CSS de la barra con la bandera `mac` del payload).
|
||||||
const MACOS_TITLEBAR_H: f64 = 28.0;
|
|
||||||
|
|
||||||
// Escalones de zoom (como un navegador). 1.0 = 100%.
|
// Escalones de zoom (como un navegador). 1.0 = 100%.
|
||||||
const ZOOM_STEPS: &[f64] = &[0.5, 0.67, 0.75, 0.8, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5];
|
const ZOOM_STEPS: &[f64] = &[0.5, 0.67, 0.75, 0.8, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5];
|
||||||
@@ -65,8 +67,26 @@ struct TabRec {
|
|||||||
label: String,
|
label: String,
|
||||||
title: String,
|
title: String,
|
||||||
url: String,
|
url: String,
|
||||||
|
loading: bool, // la barra pinta un giro en el icono mientras carga
|
||||||
|
// Color elegido a mano desde el menú de la pestaña (None = sin teñir). Aquí solo vive el
|
||||||
|
// NOMBRE; el tono exacto y cómo se pinta son cosa del CSS de la barra.
|
||||||
|
color: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Paleta de colores de pestaña, la misma idea que los grupos de Chrome: sirve para agrupar de
|
||||||
|
// un vistazo («todo lo de este cliente en verde»). El id viaja en el payload de `ls-tabs`.
|
||||||
|
const TAB_COLORS: &[(&str, &str)] = &[
|
||||||
|
("gris", "Gris"),
|
||||||
|
("azul", "Azul"),
|
||||||
|
("rojo", "Rojo"),
|
||||||
|
("amarillo", "Amarillo"),
|
||||||
|
("verde", "Verde"),
|
||||||
|
("rosa", "Rosa"),
|
||||||
|
("morado", "Morado"),
|
||||||
|
("cian", "Cian"),
|
||||||
|
("naranja", "Naranja"),
|
||||||
|
];
|
||||||
|
|
||||||
struct Shell {
|
struct Shell {
|
||||||
tabs: Vec<TabRec>,
|
tabs: Vec<TabRec>,
|
||||||
active: usize,
|
active: usize,
|
||||||
@@ -75,11 +95,19 @@ struct Shell {
|
|||||||
win: Option<WinRect>,
|
win: Option<WinRect>,
|
||||||
autostart: Option<bool>, // elección del usuario en el menú ⋮ (None = por defecto, activado)
|
autostart: Option<bool>, // elección del usuario en el menú ⋮ (None = por defecto, activado)
|
||||||
closed: Vec<String>, // URLs de pestañas cerradas (para «Reabrir pestaña cerrada», ⌘⇧T)
|
closed: Vec<String>, // URLs de pestañas cerradas (para «Reabrir pestaña cerrada», ⌘⇧T)
|
||||||
|
menu_tab: Option<String>, // pestaña sobre la que se abrió el menú de clic derecho
|
||||||
|
// Último estado maximizado conocido. Solo sirve para no repintar la barra en CADA
|
||||||
|
// evento de redimensión: únicamente cuando el icono ▢/❐ tiene que cambiar.
|
||||||
|
maximized: bool,
|
||||||
|
// Tema REAL de la app (la clase `dark` de <html>, reportada por el script inyectado).
|
||||||
|
// Es global y no por pestaña: todas las pestañas del origen comparten el mismo modo
|
||||||
|
// (localStorage). None = ninguna pestaña ha reportado aún → la barra cae al del sistema.
|
||||||
|
dark: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Shell {
|
impl Default for Shell {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { tabs: Vec::new(), active: 0, zoom_idx: ZOOM_100, next_id: 1, win: None, autostart: None, closed: Vec::new() }
|
Self { tabs: Vec::new(), active: 0, zoom_idx: ZOOM_100, next_id: 1, win: None, autostart: None, closed: Vec::new(), menu_tab: None, maximized: false, dark: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,10 +130,18 @@ struct Persisted {
|
|||||||
win: Option<WinRect>,
|
win: Option<WinRect>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
tabs: Vec<String>,
|
tabs: Vec<String>,
|
||||||
|
// Color de cada pestaña, en el mismo orden que `tabs` ("" = sin teñir). Lista aparte para
|
||||||
|
// que un estado.json viejo (sin colores) siga cargando tal cual.
|
||||||
|
#[serde(default)]
|
||||||
|
colors: Vec<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
active: usize,
|
active: usize,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
autostart: Option<bool>,
|
autostart: Option<bool>,
|
||||||
|
// Último tema conocido de la app: la barra abre ya del color correcto en vez de
|
||||||
|
// arrancar con el del sistema y dar un fogonazo al cargar la primera pestaña.
|
||||||
|
#[serde(default)]
|
||||||
|
dark: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn state_path<R: Runtime>(app: &AppHandle<R>) -> Option<std::path::PathBuf> {
|
fn state_path<R: Runtime>(app: &AppHandle<R>) -> Option<std::path::PathBuf> {
|
||||||
@@ -128,8 +164,10 @@ fn save_persisted<R: Runtime>(app: &AppHandle<R>) {
|
|||||||
zoom_idx: Some(s.zoom_idx),
|
zoom_idx: Some(s.zoom_idx),
|
||||||
win: s.win,
|
win: s.win,
|
||||||
tabs: s.tabs.iter().map(|t| t.url.clone()).collect(),
|
tabs: s.tabs.iter().map(|t| t.url.clone()).collect(),
|
||||||
|
colors: s.tabs.iter().map(|t| t.color.clone().unwrap_or_default()).collect(),
|
||||||
active: s.active,
|
active: s.active,
|
||||||
autostart: s.autostart,
|
autostart: s.autostart,
|
||||||
|
dark: s.dark,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Some(dir) = path.parent() {
|
if let Some(dir) = path.parent() {
|
||||||
@@ -146,16 +184,33 @@ fn save_persisted<R: Runtime>(app: &AppHandle<R>) {
|
|||||||
// - Reporta título/URL a la barra (observer del <title> + pushState del SPA).
|
// - Reporta título/URL a la barra (observer del <title> + pushState del SPA).
|
||||||
// - Atajos de teclado (en macOS los consume antes el menú nativo; esto cubre Windows y extras)
|
// - Atajos de teclado (en macOS los consume antes el menú nativo; esto cubre Windows y extras)
|
||||||
// y Ctrl+rueda para zoom.
|
// y Ctrl+rueda para zoom.
|
||||||
// En páginas de OTRO origen (p. ej. el login de Authentik) __TAURI__ no está inyectado y el
|
// SOLO debe gobernar el documento principal de NUESTRO origen; ver la guarda de abajo.
|
||||||
// script sale al principio sin tocar nada — la navegación del SSO sigue intacta.
|
|
||||||
const INIT_JS_TPL: &str = r#"
|
const INIT_JS_TPL: &str = r#"
|
||||||
(function () {
|
(function () {
|
||||||
|
var ORIGIN = "__ORIGIN__";
|
||||||
|
|
||||||
|
// ── GUARDA DE MARCO Y ORIGEN ──
|
||||||
|
// Antes aquí solo estaba `if (!T || !T.event) return;`, confiando en que __TAURI__ no
|
||||||
|
// existiría fuera del origen permitido. Eso es cierto en macOS y FALSO en Windows:
|
||||||
|
// · wry inyecta los scripts de inicio en TODOS los marcos e IGNORA for_main_frame_only
|
||||||
|
// (wry-0.55.1/src/webview2/mod.rs:492-495, documentado en su lib.rs:990), mientras que
|
||||||
|
// WKWebView sí la respeta (wry-0.55.1/src/wkwebview/mod.rs:643-645);
|
||||||
|
// · y __TAURI__ viaja con ellos (withGlobalTauri, tauri/src/manager/webview.rs:159-165).
|
||||||
|
// Consecuencia real: dentro del iframe del editor de OnlyOffice (docs.labstreamsas.com)
|
||||||
|
// este script SÍ corría en Windows, con ORIGIN apuntando todavía a la app. Como allí
|
||||||
|
// `location.href` es el del Document Server, abs() resolvía CADA enlace del editor contra
|
||||||
|
// docs.* → isExt() cierto → preventDefault() + mandarlo al navegador del sistema (que no
|
||||||
|
// tiene la sesión: «no se puede acceder»), y window.open devolvía null. Por eso editar y
|
||||||
|
// descargar fallaban solo en la app de Windows, y no en Mac ni en el navegador.
|
||||||
|
// En macOS estas dos líneas son un no-op: allí el script nunca ha corrido en subframes.
|
||||||
|
try { if (window.top !== window.self) return; } catch (e) { return; }
|
||||||
|
if (location.origin !== ORIGIN) return; // p. ej. el login del SSO: no intervenir
|
||||||
|
|
||||||
if (window.__lsShell) return;
|
if (window.__lsShell) return;
|
||||||
window.__lsShell = true;
|
window.__lsShell = true;
|
||||||
var T = window.__TAURI__;
|
var T = window.__TAURI__;
|
||||||
if (!T || !T.event) return; // página fuera del origen permitido (p. ej. SSO): no intervenir
|
if (!T || !T.event) return;
|
||||||
var LABEL = "__LABEL__";
|
var LABEL = "__LABEL__";
|
||||||
var ORIGIN = "__ORIGIN__";
|
|
||||||
|
|
||||||
function abs(h) { try { return new URL(h, location.href); } catch (e) { return null; } }
|
function abs(h) { try { return new URL(h, location.href); } catch (e) { return null; } }
|
||||||
function isHttp(u) { return !!u && (u.protocol === 'http:' || u.protocol === 'https:'); }
|
function isHttp(u) { return !!u && (u.protocol === 'http:' || u.protocol === 'https:'); }
|
||||||
@@ -168,9 +223,39 @@ const INIT_JS_TPL: &str = r#"
|
|||||||
}
|
}
|
||||||
function newTab(url) { emit('ls-new-tab', { url: url }); }
|
function newTab(url) { emit('ls-new-tab', { url: url }); }
|
||||||
|
|
||||||
// Título y URL → barra de pestañas (y para restaurar la sesión al reabrir).
|
// ── ¿La página se VE oscura? ──
|
||||||
|
// Señales, de la más directa a la más física: la clase `dark` (next-themes) y, si no
|
||||||
|
// está, el color de fondo REALMENTE pintado (luminancia del body) — vale sea cual sea
|
||||||
|
// el mecanismo de tema. Devuelve null con el documento a medio crear (los scripts de
|
||||||
|
// inicio corren antes de que exista <html>): entonces el campo NO viaja y Rust conserva
|
||||||
|
// el último valor bueno. La v1.7.0 leía la clase a secas y sin red: en WebView2 eso
|
||||||
|
// podía reventar en frío y dejar `dark` mintiendo en estado.json (barra clara sobre
|
||||||
|
// app oscura — el bug al revés).
|
||||||
|
function temaOscuro() {
|
||||||
|
try {
|
||||||
|
var doc = document.documentElement, cuerpo = document.body;
|
||||||
|
if (!doc) return null;
|
||||||
|
if (doc.classList.contains('dark') || (cuerpo && cuerpo.classList.contains('dark'))) return true;
|
||||||
|
if (!cuerpo) return null;
|
||||||
|
var fondo = getComputedStyle(cuerpo).backgroundColor || '';
|
||||||
|
var m = fondo.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s\/]+([\d.]+))?/);
|
||||||
|
if (m && (m[4] === undefined || parseFloat(m[4]) > 0.5)) {
|
||||||
|
return 0.2126 * m[1] + 0.7152 * m[2] + 0.0722 * m[3] < 128;
|
||||||
|
}
|
||||||
|
var esquema = getComputedStyle(doc).colorScheme || '';
|
||||||
|
if (esquema.indexOf('dark') >= 0 && esquema.indexOf('light') < 0) return true;
|
||||||
|
return false;
|
||||||
|
} catch (e) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Título, URL y TEMA → barra de pestañas (y para restaurar la sesión al reabrir).
|
||||||
|
// El tema viaja aquí porque la web decide su modo con su propio botón y NO sigue al
|
||||||
|
// sistema: la barra tiene que copiarle a ELLA.
|
||||||
function report() {
|
function report() {
|
||||||
emit('ls-title', { label: LABEL, title: document.title || 'Labstream OS', url: location.href });
|
var carga = { label: LABEL, title: document.title || 'Labstream OS', url: location.href };
|
||||||
|
var oscuro = temaOscuro();
|
||||||
|
if (oscuro !== null) carga.dark = oscuro;
|
||||||
|
emit('ls-title', carga);
|
||||||
}
|
}
|
||||||
function watchTitle() {
|
function watchTitle() {
|
||||||
var el = document.querySelector('title');
|
var el = document.querySelector('title');
|
||||||
@@ -189,6 +274,18 @@ const INIT_JS_TPL: &str = r#"
|
|||||||
history[k] = function () { var r = o.apply(this, arguments); setTimeout(report, 0); return r; };
|
history[k] = function () { var r = o.apply(this, arguments); setTimeout(report, 0); return r; };
|
||||||
});
|
});
|
||||||
addEventListener('popstate', function () { setTimeout(report, 0); });
|
addEventListener('popstate', function () { setTimeout(report, 0); });
|
||||||
|
// Pulsar la luna cambia clases/estilos sin navegar: se vigilan <html> y <body> (cuando
|
||||||
|
// existan — a document-start aún no hay), y tras la carga se re-reporta un par de veces
|
||||||
|
// por si el tema aterriza tarde con la hidratación.
|
||||||
|
function vigilarTema() {
|
||||||
|
if (!window.MutationObserver) return;
|
||||||
|
var conf = { attributes: true, attributeFilter: ['class', 'style', 'data-theme'] };
|
||||||
|
if (document.documentElement) new MutationObserver(report).observe(document.documentElement, conf);
|
||||||
|
if (document.body) new MutationObserver(report).observe(document.body, conf);
|
||||||
|
}
|
||||||
|
if (document.body) vigilarTema();
|
||||||
|
else document.addEventListener('DOMContentLoaded', vigilarTema);
|
||||||
|
addEventListener('load', function () { setTimeout(report, 800); setTimeout(report, 2500); });
|
||||||
|
|
||||||
// Clics en enlaces.
|
// Clics en enlaces.
|
||||||
document.addEventListener('click', function (e) {
|
document.addEventListener('click', function (e) {
|
||||||
@@ -222,6 +319,11 @@ const INIT_JS_TPL: &str = r#"
|
|||||||
|
|
||||||
// Atajos de teclado.
|
// Atajos de teclado.
|
||||||
addEventListener('keydown', function (e) {
|
addEventListener('keydown', function (e) {
|
||||||
|
// AltGr enciende ctrlKey en Windows. Sin este filtro, escribir [ o ] con teclado
|
||||||
|
// español —que se hacen con AltGr— entraba por aquí y disparaba history.back() /
|
||||||
|
// history.forward() en vez de escribir el carácter: en el editor, en el chat, en una
|
||||||
|
// nota y en cualquier campo de la app. En macOS no aplica (Option no toca ctrlKey).
|
||||||
|
if (e.altKey) return;
|
||||||
var mod = e.metaKey || e.ctrlKey;
|
var mod = e.metaKey || e.ctrlKey;
|
||||||
if (!mod) return;
|
if (!mod) return;
|
||||||
var k = e.key;
|
var k = e.key;
|
||||||
@@ -271,40 +373,19 @@ fn get_webview<R: Runtime>(app: &AppHandle<R>, label: &str) -> Option<Webview<R>
|
|||||||
main_window(app).and_then(|w| w.webviews().into_iter().find(|v| v.label() == label))
|
main_window(app).and_then(|w| w.webviews().into_iter().find(|v| v.label() == label))
|
||||||
}
|
}
|
||||||
|
|
||||||
// En macOS las coordenadas de los webviews HIJOS son relativas al MARCO de la ventana
|
|
||||||
// (incluye la barra de título) y `inner_size()` devuelve también el marco. Sin compensar,
|
|
||||||
// la barra de pestañas se dibuja DEBAJO del título nativo y solo asoman ~12 px (además el
|
|
||||||
// título translúcido se teñía del color de la barra). Se detecta en caliente: si el marco y
|
|
||||||
// el interior miden lo mismo hay que compensar; si Tauri lo corrige, la resta deja de ser 0
|
|
||||||
// y no se compensa nada. En Windows/Linux siempre es 0 (ahí las coordenadas ya son del área
|
|
||||||
// de cliente).
|
|
||||||
fn top_offset<R: Runtime>(win: &Window<R>, scale: f64) -> f64 {
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
if let (Ok(outer), Ok(inner)) = (win.outer_size(), win.inner_size()) {
|
|
||||||
let o = outer.to_logical::<f64>(scale).height;
|
|
||||||
let i = inner.to_logical::<f64>(scale).height;
|
|
||||||
if (o - i).abs() < 1.0 {
|
|
||||||
return MACOS_TITLEBAR_H;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let _ = (win, scale);
|
|
||||||
0.0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Geometría: barra arriba (alto fijo), contenido debajo ocupando el resto.
|
// Geometría: barra arriba (alto fijo), contenido debajo ocupando el resto.
|
||||||
fn layout_all<R: Runtime>(app: &AppHandle<R>) {
|
fn layout_all<R: Runtime>(app: &AppHandle<R>) {
|
||||||
let Some(win) = main_window(app) else { return };
|
let Some(win) = main_window(app) else { return };
|
||||||
let scale = win.scale_factor().unwrap_or(1.0);
|
let scale = win.scale_factor().unwrap_or(1.0);
|
||||||
let Ok(size) = win.inner_size() else { return };
|
let Ok(size) = win.inner_size() else { return };
|
||||||
let size = size.to_logical::<f64>(scale);
|
let size = size.to_logical::<f64>(scale);
|
||||||
let top = top_offset(&win, scale);
|
let content_h = (size.height - TAB_BAR_H).max(0.0);
|
||||||
let content_h = (size.height - top - TAB_BAR_H).max(0.0);
|
|
||||||
for wv in win.webviews() {
|
for wv in win.webviews() {
|
||||||
if wv.label() == CHROME {
|
if wv.label() == CHROME {
|
||||||
let _ = wv.set_position(LogicalPosition::new(0.0, top));
|
let _ = wv.set_position(LogicalPosition::new(0.0, 0.0));
|
||||||
let _ = wv.set_size(LogicalSize::new(size.width, TAB_BAR_H));
|
let _ = wv.set_size(LogicalSize::new(size.width, TAB_BAR_H));
|
||||||
} else {
|
} else {
|
||||||
let _ = wv.set_position(LogicalPosition::new(0.0, top + TAB_BAR_H));
|
let _ = wv.set_position(LogicalPosition::new(0.0, TAB_BAR_H));
|
||||||
let _ = wv.set_size(LogicalSize::new(size.width, content_h));
|
let _ = wv.set_size(LogicalSize::new(size.width, content_h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,6 +399,8 @@ fn current_zoom<R: Runtime>(app: &AppHandle<R>) -> f64 {
|
|||||||
|
|
||||||
// Manda el estado de pestañas + zoom + versión a la barra (webview "chrome").
|
// Manda el estado de pestañas + zoom + versión a la barra (webview "chrome").
|
||||||
fn broadcast<R: Runtime>(app: &AppHandle<R>) {
|
fn broadcast<R: Runtime>(app: &AppHandle<R>) {
|
||||||
|
// Se consulta ANTES de tomar el lock del shell: así no se anidan dos cerrojos.
|
||||||
|
let maximized = main_window(app).and_then(|w| w.is_maximized().ok()).unwrap_or(false);
|
||||||
let payload = {
|
let payload = {
|
||||||
let shell = app.state::<ShellState>();
|
let shell = app.state::<ShellState>();
|
||||||
let s = shell.lock().unwrap();
|
let s = shell.lock().unwrap();
|
||||||
@@ -325,17 +408,40 @@ fn broadcast<R: Runtime>(app: &AppHandle<R>) {
|
|||||||
.tabs
|
.tabs
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, t)| json!({ "label": t.label, "title": t.title, "active": i == s.active }))
|
.map(|(i, t)| json!({ "label": t.label, "title": t.title, "url": t.url, "loading": t.loading, "active": i == s.active, "color": t.color }))
|
||||||
.collect();
|
.collect();
|
||||||
json!({
|
json!({
|
||||||
"tabs": tabs,
|
"tabs": tabs,
|
||||||
"zoom": (ZOOM_STEPS[s.zoom_idx.min(ZOOM_STEPS.len()-1)] * 100.0).round() as u32,
|
"zoom": (ZOOM_STEPS[s.zoom_idx.min(ZOOM_STEPS.len()-1)] * 100.0).round() as u32,
|
||||||
"version": app.package_info().version.to_string(),
|
"version": app.package_info().version.to_string(),
|
||||||
|
// En macOS la barra ocupa la fila del título (ventana con título en overlay) y
|
||||||
|
// debe dejar libre el hueco del semáforo, que lo pinta el sistema.
|
||||||
|
"mac": cfg!(target_os = "macos"),
|
||||||
|
// En Windows la ventana va SIN decoración: la barra es la fila del título, así
|
||||||
|
// que dibuja ella misma los botones minimizar/maximizar/cerrar (no hay nativos).
|
||||||
|
"win": cfg!(target_os = "windows"),
|
||||||
|
"maximized": maximized,
|
||||||
|
// Tema real de la app (null hasta el primer reporte: la barra usa el del sistema).
|
||||||
|
"dark": s.dark,
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
let _ = app.emit_to(EventTarget::webview(CHROME), "ls-tabs", payload);
|
let _ = app.emit_to(EventTarget::webview(CHROME), "ls-tabs", payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Marca una pestaña como «cargando» y refresca la barra (giro en el icono).
|
||||||
|
fn set_loading<R: Runtime>(app: &AppHandle<R>, label: &str, loading: bool) {
|
||||||
|
{
|
||||||
|
let shell = app.state::<ShellState>();
|
||||||
|
let mut s = shell.lock().unwrap();
|
||||||
|
let Some(t) = s.tabs.iter_mut().find(|t| t.label == label) else { return };
|
||||||
|
if t.loading == loading {
|
||||||
|
return; // sin cambios: no repintar la barra
|
||||||
|
}
|
||||||
|
t.loading = loading;
|
||||||
|
}
|
||||||
|
broadcast(app);
|
||||||
|
}
|
||||||
|
|
||||||
// Muestra la pestaña `label` y esconde las demás. Devuelve el foco al contenido.
|
// Muestra la pestaña `label` y esconde las demás. Devuelve el foco al contenido.
|
||||||
fn activate_tab<R: Runtime>(app: &AppHandle<R>, label: &str) {
|
fn activate_tab<R: Runtime>(app: &AppHandle<R>, label: &str) {
|
||||||
{
|
{
|
||||||
@@ -378,7 +484,7 @@ fn create_tab<R: Runtime>(app: &AppHandle<R>, url: Option<String>, activate: boo
|
|||||||
let mut s = shell.lock().unwrap();
|
let mut s = shell.lock().unwrap();
|
||||||
let label = format!("tab-{}", s.next_id);
|
let label = format!("tab-{}", s.next_id);
|
||||||
s.next_id += 1;
|
s.next_id += 1;
|
||||||
s.tabs.push(TabRec { label: label.clone(), title: "Labstream OS".into(), url: target.clone() });
|
s.tabs.push(TabRec { label: label.clone(), title: "Labstream OS".into(), url: target.clone(), loading: true, color: None });
|
||||||
label
|
label
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -390,20 +496,52 @@ fn create_tab<R: Runtime>(app: &AppHandle<R>, url: Option<String>, activate: boo
|
|||||||
let app_zoom = app.clone();
|
let app_zoom = app.clone();
|
||||||
let builder = WebviewBuilder::new(&label, WebviewUrl::External(parsed))
|
let builder = WebviewBuilder::new(&label, WebviewUrl::External(parsed))
|
||||||
.initialization_script(&init)
|
.initialization_script(&init)
|
||||||
// Deja pasar las descargas (entregables, exportaciones) con el diálogo nativo de guardado.
|
// Deja pasar las descargas (entregables, exportaciones) Y avisa al terminar.
|
||||||
.on_download(|_webview, _event| true)
|
// El aviso no es un adorno: en WebView2 la interfaz de descargas queda SIEMPRE
|
||||||
|
// apagada. wry trae un manejador de descargas por defecto (wry-0.55.1/src/lib.rs:830),
|
||||||
|
// asi que DownloadStarting se registra siempre y siempre responde SetHandled(true)
|
||||||
|
// (wry-0.55.1/src/webview2/mod.rs:858-861), lo que le dice a WebView2 que del aviso
|
||||||
|
// se encarga la app: ni barra de progreso, ni globo de «descarga terminada». El
|
||||||
|
// archivo bajaba bien a la carpeta de Descargas, pero NADA lo decia y parecia roto.
|
||||||
|
// Quitar este manejador NO devuelve la interfaz nativa: el de wry sigue puesto.
|
||||||
|
.on_download(|webview, event| {
|
||||||
|
if let DownloadEvent::Finished { path, success, .. } = &event {
|
||||||
|
let cuerpo = if !*success {
|
||||||
|
"No se pudo completar la descarga.".to_string()
|
||||||
|
} else if let Some(p) = path {
|
||||||
|
// En macOS `path` llega siempre vacio (limite de WKDownload:
|
||||||
|
// wry-0.55.1/src/wkwebview/download.rs:98), asi que en la practica
|
||||||
|
// este brazo con nombre de archivo es el de Windows.
|
||||||
|
match p.file_name() {
|
||||||
|
Some(n) => format!("Descargado: {}", n.to_string_lossy()),
|
||||||
|
None => "Descarga terminada.".to_string(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
"Descarga terminada. Esta en tu carpeta de Descargas.".to_string()
|
||||||
|
};
|
||||||
|
let _ = webview
|
||||||
|
.app_handle()
|
||||||
|
.notification()
|
||||||
|
.builder()
|
||||||
|
.title("Labstream OS")
|
||||||
|
.body(cuerpo)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
true
|
||||||
|
})
|
||||||
// El zoom guardado se re-aplica en cada carga (el factor no siempre sobrevive a la navegación).
|
// El zoom guardado se re-aplica en cada carga (el factor no siempre sobrevive a la navegación).
|
||||||
.on_page_load(move |wv, payload| {
|
.on_page_load(move |wv, payload| {
|
||||||
if let PageLoadEvent::Finished = payload.event() {
|
let cargando = matches!(payload.event(), PageLoadEvent::Started);
|
||||||
|
if !cargando {
|
||||||
let _ = wv.set_zoom(current_zoom(&app_zoom));
|
let _ = wv.set_zoom(current_zoom(&app_zoom));
|
||||||
}
|
}
|
||||||
|
set_loading(&app_zoom, wv.label(), cargando);
|
||||||
});
|
});
|
||||||
|
|
||||||
let top = top_offset(&win, scale);
|
|
||||||
let created = win.add_child(
|
let created = win.add_child(
|
||||||
builder,
|
builder,
|
||||||
LogicalPosition::new(0.0, top + TAB_BAR_H),
|
LogicalPosition::new(0.0, TAB_BAR_H),
|
||||||
LogicalSize::new(size.width, (size.height - top - TAB_BAR_H).max(0.0)),
|
LogicalSize::new(size.width, (size.height - TAB_BAR_H).max(0.0)),
|
||||||
);
|
);
|
||||||
|
|
||||||
match created {
|
match created {
|
||||||
@@ -642,6 +780,134 @@ fn show_app_menu<R: Runtime>(app: &AppHandle<R>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Menú de CLIC DERECHO sobre una pestaña. Nativo (la barra mide 40 px: un menú HTML dentro
|
||||||
|
// del webview quedaría recortado). Recuerda en el estado sobre qué pestaña se abrió.
|
||||||
|
fn show_tab_menu<R: Runtime>(app: &AppHandle<R>, label: &str) {
|
||||||
|
let Some(win) = main_window(app) else { return };
|
||||||
|
let (idx, total, actual) = {
|
||||||
|
let shell = app.state::<ShellState>();
|
||||||
|
let mut s = shell.lock().unwrap();
|
||||||
|
let Some(i) = s.tabs.iter().position(|t| t.label == label) else { return };
|
||||||
|
s.menu_tab = Some(label.to_string());
|
||||||
|
let actual = s.tabs[i].color.clone();
|
||||||
|
(i, s.tabs.len(), actual)
|
||||||
|
};
|
||||||
|
// Los ids se arman fuera del builder para poder pasarlos como &str (igual que el resto
|
||||||
|
// del menú) en vez de mezclar String y &str en el mismo constructor.
|
||||||
|
let ids: Vec<String> = TAB_COLORS.iter().map(|(id, _)| format!("tab-color-{id}")).collect();
|
||||||
|
let build = || -> tauri::Result<Menu<R>> {
|
||||||
|
// Submenú de color, con marca en el que tiene puesto ahora.
|
||||||
|
let mut colores: Vec<CheckMenuItem<R>> = Vec::with_capacity(TAB_COLORS.len() + 1);
|
||||||
|
colores.push(CheckMenuItem::with_id(app, "tab-color-ninguno", "Sin color", true, actual.is_none(), None::<&str>)?);
|
||||||
|
for ((cid, nombre), id) in TAB_COLORS.iter().zip(ids.iter()) {
|
||||||
|
let marcado = actual.as_deref() == Some(*cid);
|
||||||
|
colores.push(CheckMenuItem::with_id(app, id.as_str(), *nombre, true, marcado, None::<&str>)?);
|
||||||
|
}
|
||||||
|
let refs: Vec<&dyn tauri::menu::IsMenuItem<R>> = colores.iter().map(|c| c as &dyn tauri::menu::IsMenuItem<R>).collect();
|
||||||
|
let submenu = Submenu::with_items(app, "Color", true, &refs)?;
|
||||||
|
Ok(Menu::with_items(
|
||||||
|
app,
|
||||||
|
&[
|
||||||
|
&MenuItem::with_id(app, "tab-duplicate", "Duplicar pestaña", true, None::<&str>)?,
|
||||||
|
&MenuItem::with_id(app, "tab-copy-url", "Copiar enlace", true, None::<&str>)?,
|
||||||
|
&PredefinedMenuItem::separator(app)?,
|
||||||
|
&submenu,
|
||||||
|
&PredefinedMenuItem::separator(app)?,
|
||||||
|
&MenuItem::with_id(app, "tab-close", "Cerrar pestaña", true, None::<&str>)?,
|
||||||
|
&MenuItem::with_id(app, "tab-close-others", "Cerrar las demás", total > 1, None::<&str>)?,
|
||||||
|
&MenuItem::with_id(app, "tab-close-right", "Cerrar las de la derecha", idx + 1 < total, None::<&str>)?,
|
||||||
|
],
|
||||||
|
)?)
|
||||||
|
};
|
||||||
|
if let Ok(menu) = build() {
|
||||||
|
let _ = win.popup_menu(&menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acciones del menú de pestaña. `menu_tab` guarda sobre cuál se abrió (puede no ser la activa).
|
||||||
|
fn tab_menu_action<R: Runtime>(app: &AppHandle<R>, action: &str) {
|
||||||
|
let target = {
|
||||||
|
let shell = app.state::<ShellState>();
|
||||||
|
let s = shell.lock().unwrap();
|
||||||
|
s.menu_tab.clone()
|
||||||
|
};
|
||||||
|
let Some(label) = target else { return };
|
||||||
|
// Las que hay que cerrar se calculan ANTES de cerrar nada (los índices se mueven).
|
||||||
|
let (url, otras, derecha) = {
|
||||||
|
let shell = app.state::<ShellState>();
|
||||||
|
let s = shell.lock().unwrap();
|
||||||
|
let Some(i) = s.tabs.iter().position(|t| t.label == label) else { return };
|
||||||
|
(
|
||||||
|
s.tabs[i].url.clone(),
|
||||||
|
s.tabs.iter().filter(|t| t.label != label).map(|t| t.label.clone()).collect::<Vec<_>>(),
|
||||||
|
s.tabs.iter().skip(i + 1).map(|t| t.label.clone()).collect::<Vec<_>>(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
match action {
|
||||||
|
"tab-duplicate" => create_tab(app, Some(url), true),
|
||||||
|
"tab-copy-url" => {
|
||||||
|
let _ = app.clipboard().write_text(url);
|
||||||
|
}
|
||||||
|
"tab-close" => close_tab(app, &label),
|
||||||
|
"tab-close-others" => {
|
||||||
|
for l in otras {
|
||||||
|
close_tab(app, &l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"tab-close-right" => {
|
||||||
|
for l in derecha {
|
||||||
|
close_tab(app, &l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Teñir la pestaña (o quitarle el color). Se valida contra la paleta: un id que no
|
||||||
|
// esté en TAB_COLORS deja la pestaña sin color en vez de guardar cualquier cosa.
|
||||||
|
a if a.starts_with("tab-color-") => {
|
||||||
|
let elegido = &a["tab-color-".len()..];
|
||||||
|
let nuevo = TAB_COLORS
|
||||||
|
.iter()
|
||||||
|
.find(|(id, _)| *id == elegido)
|
||||||
|
.map(|(id, _)| (*id).to_string());
|
||||||
|
{
|
||||||
|
let shell = app.state::<ShellState>();
|
||||||
|
let mut s = shell.lock().unwrap();
|
||||||
|
if let Some(t) = s.tabs.iter_mut().find(|t| t.label == label) {
|
||||||
|
t.color = nuevo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
broadcast(app);
|
||||||
|
save_persisted(app);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reordena las pestañas al soltar una en otra posición (arrastrar en la barra). Llega el
|
||||||
|
// orden completo de etiquetas; se conserva cuál estaba activa y se guarda la sesión.
|
||||||
|
fn reorder_tabs<R: Runtime>(app: &AppHandle<R>, order: Vec<String>) {
|
||||||
|
{
|
||||||
|
let shell = app.state::<ShellState>();
|
||||||
|
let mut s = shell.lock().unwrap();
|
||||||
|
// Solo se acepta una permutación EXACTA de las pestañas actuales (nada de perder o
|
||||||
|
// duplicar si la barra manda algo raro).
|
||||||
|
if order.len() != s.tabs.len() || !order.iter().all(|l| s.tabs.iter().any(|t| &t.label == l)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let activa = s.tabs.get(s.active).map(|t| t.label.clone());
|
||||||
|
let mut nuevas: Vec<TabRec> = Vec::with_capacity(order.len());
|
||||||
|
for l in &order {
|
||||||
|
if let Some(i) = s.tabs.iter().position(|t| &t.label == l) {
|
||||||
|
nuevas.push(s.tabs.remove(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.tabs = nuevas;
|
||||||
|
if let Some(a) = activa {
|
||||||
|
s.active = s.tabs.iter().position(|t| t.label == a).unwrap_or(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
broadcast(app);
|
||||||
|
save_persisted(app);
|
||||||
|
}
|
||||||
|
|
||||||
// Activa/desactiva el arranque con el sistema y RECUERDA la elección (si no, el arranque
|
// Activa/desactiva el arranque con el sistema y RECUERDA la elección (si no, el arranque
|
||||||
// la re-activaba en cada apertura).
|
// la re-activaba en cada apertura).
|
||||||
fn toggle_autostart<R: Runtime>(app: &AppHandle<R>) {
|
fn toggle_autostart<R: Runtime>(app: &AppHandle<R>) {
|
||||||
@@ -734,6 +1000,10 @@ fn field_i64(payload: &str, key: &str) -> Option<i64> {
|
|||||||
serde_json::from_str::<serde_json::Value>(payload).ok()?.get(key)?.as_i64()
|
serde_json::from_str::<serde_json::Value>(payload).ok()?.get(key)?.as_i64()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn field_bool(payload: &str, key: &str) -> Option<bool> {
|
||||||
|
serde_json::from_str::<serde_json::Value>(payload).ok()?.get(key)?.as_bool()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
let mut builder = tauri::Builder::default();
|
let mut builder = tauri::Builder::default();
|
||||||
@@ -748,6 +1018,7 @@ pub fn run() {
|
|||||||
|
|
||||||
builder = builder
|
builder = builder
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
|
.plugin(tauri_plugin_clipboard_manager::init())
|
||||||
.plugin(tauri_plugin_notification::init())
|
.plugin(tauri_plugin_notification::init())
|
||||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||||
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, None));
|
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, None));
|
||||||
@@ -782,13 +1053,30 @@ pub fn run() {
|
|||||||
s.zoom_idx = saved.zoom_idx.unwrap_or(ZOOM_100).min(ZOOM_STEPS.len() - 1);
|
s.zoom_idx = saved.zoom_idx.unwrap_or(ZOOM_100).min(ZOOM_STEPS.len() - 1);
|
||||||
s.win = saved.win;
|
s.win = saved.win;
|
||||||
s.autostart = saved.autostart;
|
s.autostart = saved.autostart;
|
||||||
|
s.dark = saved.dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ventana principal (contenedora). Tamaño/posición de la sesión anterior si los hay.
|
// Ventana principal (contenedora). Tamaño/posición de la sesión anterior si los hay.
|
||||||
|
// En AMBOS sistemas la barra de pestañas ocupa la fila del título, como Chrome:
|
||||||
|
// no se desperdicia una franja entera en repetir el nombre de la app.
|
||||||
|
// - macOS: título en OVERLAY y sin texto; el semáforo lo sigue pintando el sistema
|
||||||
|
// encima y la barra le deja su hueco (clase `mac` del CSS).
|
||||||
|
// - Windows: ventana SIN decoración; los botones minimizar/maximizar/cerrar los
|
||||||
|
// dibuja la propia barra (clase `win`) y actúan por el evento `ls-window`.
|
||||||
|
// `resizable(true)` conserva WS_THICKFRAME, así que los bordes siguen
|
||||||
|
// redimensionando y Aero Snap (arrastrar a un borde, Win+flechas) sigue vivo.
|
||||||
let mut wb = WindowBuilder::new(app, "main")
|
let mut wb = WindowBuilder::new(app, "main")
|
||||||
.title("Labstream OS")
|
.title("Labstream OS")
|
||||||
.resizable(true)
|
.resizable(true)
|
||||||
.min_inner_size(1024.0, 700.0);
|
.min_inner_size(1024.0, 700.0);
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
wb = wb.title_bar_style(tauri::TitleBarStyle::Overlay).hidden_title(true);
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
wb = wb.decorations(false);
|
||||||
|
}
|
||||||
match saved.win {
|
match saved.win {
|
||||||
Some(r) if r.w >= 600.0 && r.h >= 400.0 => {
|
Some(r) if r.w >= 600.0 && r.h >= 400.0 => {
|
||||||
wb = wb.inner_size(r.w, r.h).position(r.x, r.y);
|
wb = wb.inner_size(r.w, r.h).position(r.x, r.y);
|
||||||
@@ -900,6 +1188,10 @@ pub fn run() {
|
|||||||
let _ = app.opener().open_url(url, None::<&str>);
|
let _ = app.opener().open_url(url, None::<&str>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
id @ ("tab-duplicate" | "tab-copy-url" | "tab-close" | "tab-close-others" | "tab-close-right") => {
|
||||||
|
tab_menu_action(app, id)
|
||||||
|
}
|
||||||
|
id if id.starts_with("tab-color-") => tab_menu_action(app, id),
|
||||||
"autostart-toggle" => toggle_autostart(app),
|
"autostart-toggle" => toggle_autostart(app),
|
||||||
"check-update" => {
|
"check-update" => {
|
||||||
#[cfg(desktop)]
|
#[cfg(desktop)]
|
||||||
@@ -916,27 +1208,44 @@ pub fn run() {
|
|||||||
let scale = win.scale_factor().unwrap_or(1.0);
|
let scale = win.scale_factor().unwrap_or(1.0);
|
||||||
let size = win.inner_size()?.to_logical::<f64>(scale);
|
let size = win.inner_size()?.to_logical::<f64>(scale);
|
||||||
win.add_child(
|
win.add_child(
|
||||||
WebviewBuilder::new(CHROME, WebviewUrl::App("index.html".into())),
|
WebviewBuilder::new(CHROME, WebviewUrl::App("index.html".into()))
|
||||||
LogicalPosition::new(0.0, top_offset(&win, scale)),
|
// Sin esto Tauri instala su manejador de arrastre del SISTEMA en el
|
||||||
|
// webview y se traga los eventos HTML5 → no se podrían reordenar las
|
||||||
|
// pestañas arrastrando. La barra no recibe archivos, así que sobra.
|
||||||
|
.disable_drag_drop_handler(),
|
||||||
|
LogicalPosition::new(0.0, 0.0),
|
||||||
LogicalSize::new(size.width, TAB_BAR_H),
|
LogicalSize::new(size.width, TAB_BAR_H),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Pestañas de la sesión anterior (o una nueva si no hay).
|
// Pestañas de la sesión anterior (o una nueva si no hay), cada una con su color.
|
||||||
let restore: Vec<String> = {
|
// El color se empareja con su URL ANTES de filtrar: el filtro por origen puede
|
||||||
|
// descartar entradas y entonces los índices de las dos listas dejarían de casar.
|
||||||
|
let restore: Vec<(String, String)> = {
|
||||||
let server = Url::parse(SERVER_URL).expect("URL del servidor válida");
|
let server = Url::parse(SERVER_URL).expect("URL del servidor válida");
|
||||||
saved
|
saved
|
||||||
.tabs
|
.tabs
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|u| Url::parse(u).map(|p| p.origin() == server.origin()).unwrap_or(false))
|
.enumerate()
|
||||||
|
.filter(|(_, u)| Url::parse(u).map(|p| p.origin() == server.origin()).unwrap_or(false))
|
||||||
.take(12)
|
.take(12)
|
||||||
.cloned()
|
.map(|(i, u)| (u.clone(), saved.colors.get(i).cloned().unwrap_or_default()))
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
if restore.is_empty() {
|
if restore.is_empty() {
|
||||||
create_tab(&handle, None, true);
|
create_tab(&handle, None, true);
|
||||||
} else {
|
} else {
|
||||||
for url in &restore {
|
for (url, color) in &restore {
|
||||||
create_tab(&handle, Some(url.clone()), false);
|
create_tab(&handle, Some(url.clone()), false);
|
||||||
|
if !color.is_empty() {
|
||||||
|
// create_tab acaba de empujar su pestaña al final de la lista.
|
||||||
|
let shell = handle.state::<ShellState>();
|
||||||
|
let mut s = shell.lock().unwrap();
|
||||||
|
if let Some(t) = s.tabs.last_mut() {
|
||||||
|
if t.url == *url {
|
||||||
|
t.color = Some(color.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let idx = saved.active.min(restore.len() - 1);
|
let idx = saved.active.min(restore.len() - 1);
|
||||||
let label = {
|
let label = {
|
||||||
@@ -1009,9 +1318,48 @@ pub fn run() {
|
|||||||
set_badge(&h, n);
|
set_badge(&h, n);
|
||||||
});
|
});
|
||||||
let h = handle.clone();
|
let h = handle.clone();
|
||||||
|
let h_tabmenu = handle.clone();
|
||||||
|
handle.listen_any("ls-tab-menu", move |e| {
|
||||||
|
if let Some(label) = field(e.payload(), "label") {
|
||||||
|
show_tab_menu(&h_tabmenu, &label);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let h_reorder = handle.clone();
|
||||||
|
handle.listen_any("ls-reorder", move |e| {
|
||||||
|
// `order` llega como lista de etiquetas separadas por coma (el payload de los
|
||||||
|
// eventos del shell es plano: strings y números).
|
||||||
|
if let Some(orden) = field(e.payload(), "order") {
|
||||||
|
let v: Vec<String> = orden.split(',').map(|x| x.trim().to_string()).filter(|x| !x.is_empty()).collect();
|
||||||
|
reorder_tabs(&h_reorder, v);
|
||||||
|
}
|
||||||
|
});
|
||||||
handle.listen_any("ls-menu", move |_| {
|
handle.listen_any("ls-menu", move |_| {
|
||||||
show_app_menu(&h);
|
show_app_menu(&h);
|
||||||
});
|
});
|
||||||
|
// Botones de ventana de la barra. Solo se pintan en Windows, donde la ventana va
|
||||||
|
// sin decoración y no hay aspa del sistema. «close» pasa por CloseRequested, así
|
||||||
|
// que hace lo mismo de siempre: ocultar a la bandeja, no salir de la app.
|
||||||
|
let h = handle.clone();
|
||||||
|
handle.listen_any("ls-window", move |e| {
|
||||||
|
let Some(win) = main_window(&h) else { return };
|
||||||
|
match field(e.payload(), "act").as_deref() {
|
||||||
|
Some("min") => {
|
||||||
|
let _ = win.minimize();
|
||||||
|
}
|
||||||
|
Some("max") => {
|
||||||
|
// El repintado del icono ▢/❐ lo dispara el Resized que viene después.
|
||||||
|
if win.is_maximized().unwrap_or(false) {
|
||||||
|
let _ = win.unmaximize();
|
||||||
|
} else {
|
||||||
|
let _ = win.maximize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some("close") => {
|
||||||
|
let _ = win.close();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
});
|
||||||
// Clic en la etiqueta de versión de la barra → buscar actualización (con aviso).
|
// Clic en la etiqueta de versión de la barra → buscar actualización (con aviso).
|
||||||
let h = handle.clone();
|
let h = handle.clone();
|
||||||
handle.listen_any("ls-check-update", move |_| {
|
handle.listen_any("ls-check-update", move |_| {
|
||||||
@@ -1020,10 +1368,11 @@ pub fn run() {
|
|||||||
});
|
});
|
||||||
let h = handle.clone();
|
let h = handle.clone();
|
||||||
handle.listen_any("ls-title", move |e| {
|
handle.listen_any("ls-title", move |e| {
|
||||||
let (label, title, url) = (
|
let (label, title, url, dark) = (
|
||||||
field(e.payload(), "label"),
|
field(e.payload(), "label"),
|
||||||
field(e.payload(), "title"),
|
field(e.payload(), "title"),
|
||||||
field(e.payload(), "url"),
|
field(e.payload(), "url"),
|
||||||
|
field_bool(e.payload(), "dark"),
|
||||||
);
|
);
|
||||||
if let Some(label) = label {
|
if let Some(label) = label {
|
||||||
let shell = h.state::<ShellState>();
|
let shell = h.state::<ShellState>();
|
||||||
@@ -1036,16 +1385,24 @@ pub fn run() {
|
|||||||
t.url = url;
|
t.url = url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// El tema es global (todas las pestañas del origen comparten modo): el
|
||||||
|
// último reporte manda, venga de la pestaña que venga.
|
||||||
|
if let Some(dark) = dark {
|
||||||
|
s.dark = Some(dark);
|
||||||
|
}
|
||||||
drop(s);
|
drop(s);
|
||||||
broadcast(&h);
|
broadcast(&h);
|
||||||
save_persisted(&h);
|
save_persisted(&h);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Icono en la bandeja del sistema con menú Abrir / Salir.
|
// Icono en la bandeja: Abrir / estado del rastreador + pausa / Salir.
|
||||||
let abrir = MenuItem::with_id(app, "abrir", "Abrir Labstream", true, None::<&str>)?;
|
let abrir = MenuItem::with_id(app, "abrir", "Abrir Labstream", true, None::<&str>)?;
|
||||||
let salir = MenuItem::with_id(app, "salir", "Salir", true, None::<&str>)?;
|
let salir = MenuItem::with_id(app, "salir", "Salir", true, None::<&str>)?;
|
||||||
let menu = Menu::with_items(app, &[&abrir, &salir])?;
|
let (trk_estado, trk_toggle) = tracker::armar_menu(app.handle())?;
|
||||||
|
let sep1 = PredefinedMenuItem::separator(app)?;
|
||||||
|
let sep2 = PredefinedMenuItem::separator(app)?;
|
||||||
|
let menu = Menu::with_items(app, &[&abrir, &sep1, &trk_estado, &trk_toggle, &sep2, &salir])?;
|
||||||
|
|
||||||
TrayIconBuilder::with_id("main-tray")
|
TrayIconBuilder::with_id("main-tray")
|
||||||
.icon(app.default_window_icon().unwrap().clone())
|
.icon(app.default_window_icon().unwrap().clone())
|
||||||
@@ -1058,6 +1415,7 @@ pub fn run() {
|
|||||||
save_persisted(app);
|
save_persisted(app);
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
}
|
}
|
||||||
|
id if tracker::menu_event(app, id) => {}
|
||||||
_ => {}
|
_ => {}
|
||||||
})
|
})
|
||||||
.on_tray_icon_event(|tray, event| {
|
.on_tray_icon_event(|tray, event| {
|
||||||
@@ -1073,6 +1431,9 @@ pub fn run() {
|
|||||||
})
|
})
|
||||||
.build(app)?;
|
.build(app)?;
|
||||||
|
|
||||||
|
// El sensor del rastreador: listener de vinculación + hilo de medición.
|
||||||
|
tracker::iniciar(app.handle());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.on_window_event(|window, event| {
|
.on_window_event(|window, event| {
|
||||||
@@ -1087,6 +1448,24 @@ pub fn run() {
|
|||||||
WindowEvent::Resized(_) | WindowEvent::ScaleFactorChanged { .. } => {
|
WindowEvent::Resized(_) | WindowEvent::ScaleFactorChanged { .. } => {
|
||||||
let app = window.app_handle();
|
let app = window.app_handle();
|
||||||
layout_all(app);
|
layout_all(app);
|
||||||
|
// Maximizar/restaurar llega como un Resized más: si el estado cambió, la
|
||||||
|
// barra tiene que repintar su icono ▢/❐. Se compara antes de emitir para
|
||||||
|
// no repintarla en cada píxel mientras se arrastra un borde.
|
||||||
|
let maxi = window.is_maximized().unwrap_or(false);
|
||||||
|
let cambio = {
|
||||||
|
let shell = app.state::<ShellState>();
|
||||||
|
let mut s = shell.lock().unwrap();
|
||||||
|
let antes = s.maximized;
|
||||||
|
s.maximized = maxi;
|
||||||
|
antes != maxi
|
||||||
|
};
|
||||||
|
if cambio {
|
||||||
|
broadcast(app);
|
||||||
|
}
|
||||||
|
// La geometría MAXIMIZADA no se guarda: al reabrir volvería como ventana
|
||||||
|
// normal del tamaño de la pantalla y, sin decoración, taparía la barra de
|
||||||
|
// tareas. Se conserva la última geometría restaurada.
|
||||||
|
if !maxi {
|
||||||
if let (Ok(pos), Ok(size)) = (window.outer_position(), window.inner_size()) {
|
if let (Ok(pos), Ok(size)) = (window.outer_position(), window.inner_size()) {
|
||||||
let scale = window.scale_factor().unwrap_or(1.0);
|
let scale = window.scale_factor().unwrap_or(1.0);
|
||||||
let p = pos.to_logical::<f64>(scale);
|
let p = pos.to_logical::<f64>(scale);
|
||||||
@@ -1096,8 +1475,12 @@ pub fn run() {
|
|||||||
Some(WinRect { x: p.x, y: p.y, w: s.width, h: s.height });
|
Some(WinRect { x: p.x, y: p.y, w: s.width, h: s.height });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
WindowEvent::Moved(_) => {
|
WindowEvent::Moved(_) => {
|
||||||
let app = window.app_handle();
|
let app = window.app_handle();
|
||||||
|
if window.is_maximized().unwrap_or(false) {
|
||||||
|
return; // ver arriba: maximizada no se guarda
|
||||||
|
}
|
||||||
if let (Ok(pos), Ok(size)) = (window.outer_position(), window.inner_size()) {
|
if let (Ok(pos), Ok(size)) = (window.outer_position(), window.inner_size()) {
|
||||||
let scale = window.scale_factor().unwrap_or(1.0);
|
let scale = window.scale_factor().unwrap_or(1.0);
|
||||||
let p = pos.to_logical::<f64>(scale);
|
let p = pos.to_logical::<f64>(scale);
|
||||||
|
|||||||
397
src-tauri/src/tracker.rs
Archivo normal
397
src-tauri/src/tracker.rs
Archivo normal
@@ -0,0 +1,397 @@
|
|||||||
|
// ── Rastreador de trabajo efectivo (Fase 1) ──
|
||||||
|
//
|
||||||
|
// Mide TIEMPO CON EL EQUIPO ACTIVO y en qué app: cada 5 s mira la ventana al frente
|
||||||
|
// (active-win-pos-rs) y si hubo entrada de mouse/teclado (device_query). Con 3 minutos sin
|
||||||
|
// entrada deja de contar (ocio profundo); bloquear la pantalla o suspender cae en lo mismo
|
||||||
|
// porque tampoco hay entrada. Acumula bloques {app, título, segundos, segundos activos} y los
|
||||||
|
// sube cada 5 min a POST /api/tracker con el token del equipo (ltk_). Sin red, la cola
|
||||||
|
// persiste en disco y reintenta.
|
||||||
|
//
|
||||||
|
// LO QUE NO HACE, a propósito: no registra teclas ni posiciones (solo "hubo entrada"), no
|
||||||
|
// toma pantallazos, no lista procesos de fondo. El estado es VISIBLE en el menú de la
|
||||||
|
// bandeja, con pausa de un toque — medición transparente, no spyware.
|
||||||
|
//
|
||||||
|
// La vinculación llega por el evento `ls-tracker-token`: la página de Ajustes → Perfil
|
||||||
|
// (dentro de la app, con la sesión del usuario) genera el token en el servidor y lo emite;
|
||||||
|
// aquí se guarda en rastreador.json y el sensor arranca. Un 401 del servidor = token
|
||||||
|
// revocado → se descarta y la bandeja vuelve a «sin vincular».
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
|
sync::Mutex,
|
||||||
|
thread,
|
||||||
|
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||||
|
};
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::json;
|
||||||
|
use tauri::{menu::MenuItem, AppHandle, Emitter, Listener, Manager, Runtime};
|
||||||
|
|
||||||
|
const API: &str = "https://os.labstreamsas.com/api/tracker";
|
||||||
|
const TICK_SEG: u64 = 5;
|
||||||
|
const OCIO_PROFUNDO_SEG: u64 = 180; // 3 min sin entrada → deja de contar
|
||||||
|
const LOTE_SEG: u64 = 300; // subir cada 5 min
|
||||||
|
const MAX_COLA_LOTES: usize = 2000; // ~1 semana sin red; después se pierde lo más viejo
|
||||||
|
const PAUSA_MANUAL: u64 = u64::MAX;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||||
|
struct Config {
|
||||||
|
token: Option<String>,
|
||||||
|
// Instante unix (seg) hasta el que está pausado; PAUSA_MANUAL = hasta reanudar a mano.
|
||||||
|
#[serde(default)]
|
||||||
|
pausado_hasta: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
struct Bloque {
|
||||||
|
s: u64, // inicio en ms unix
|
||||||
|
d: u32, // segundos del bloque
|
||||||
|
a: u32, // segundos con entrada real
|
||||||
|
app: String,
|
||||||
|
t: String, // título de ventana (truncado; puede ir vacío)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Estado compartido sensor ↔ menú. Los items de menú viven aparte (son genéricos en R).
|
||||||
|
struct Nucleo {
|
||||||
|
cfg: Config,
|
||||||
|
cola: Vec<Vec<Bloque>>, // lotes pendientes de subir
|
||||||
|
}
|
||||||
|
|
||||||
|
struct NucleoState(Mutex<Nucleo>);
|
||||||
|
struct MenuUi<R: Runtime> {
|
||||||
|
estado: MenuItem<R>,
|
||||||
|
toggle: MenuItem<R>,
|
||||||
|
}
|
||||||
|
struct MenuState<R: Runtime>(Mutex<MenuUi<R>>);
|
||||||
|
|
||||||
|
fn ahora_seg() -> u64 {
|
||||||
|
SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0)
|
||||||
|
}
|
||||||
|
fn ahora_ms() -> u64 {
|
||||||
|
SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_millis() as u64).unwrap_or(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ruta_cfg<R: Runtime>(app: &AppHandle<R>) -> Option<std::path::PathBuf> {
|
||||||
|
app.path().app_config_dir().ok().map(|d| d.join("rastreador.json"))
|
||||||
|
}
|
||||||
|
fn ruta_cola<R: Runtime>(app: &AppHandle<R>) -> Option<std::path::PathBuf> {
|
||||||
|
app.path().app_config_dir().ok().map(|d| d.join("rastreador-cola.json"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cargar_cfg<R: Runtime>(app: &AppHandle<R>) -> Config {
|
||||||
|
ruta_cfg(app)
|
||||||
|
.and_then(|p| std::fs::read_to_string(p).ok())
|
||||||
|
.and_then(|s| serde_json::from_str(&s).ok())
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
|
fn guardar_cfg<R: Runtime>(app: &AppHandle<R>, cfg: &Config) {
|
||||||
|
let Some(p) = ruta_cfg(app) else { return };
|
||||||
|
if let Some(dir) = p.parent() {
|
||||||
|
let _ = std::fs::create_dir_all(dir);
|
||||||
|
}
|
||||||
|
if let Ok(txt) = serde_json::to_string(cfg) {
|
||||||
|
let _ = std::fs::write(p, txt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn cargar_cola<R: Runtime>(app: &AppHandle<R>) -> Vec<Vec<Bloque>> {
|
||||||
|
ruta_cola(app)
|
||||||
|
.and_then(|p| std::fs::read_to_string(p).ok())
|
||||||
|
.and_then(|s| serde_json::from_str(&s).ok())
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
|
fn guardar_cola<R: Runtime>(app: &AppHandle<R>, cola: &[Vec<Bloque>]) {
|
||||||
|
let Some(p) = ruta_cola(app) else { return };
|
||||||
|
if cola.is_empty() {
|
||||||
|
let _ = std::fs::remove_file(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if let Ok(txt) = serde_json::to_string(cola) {
|
||||||
|
let _ = std::fs::write(p, txt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Menú de bandeja ──
|
||||||
|
// Crea los dos items del rastreador (estado informativo + pausar/reanudar) YA con el texto
|
||||||
|
// correcto: `set_text` de Tauri despacha al hilo principal y BLOQUEA esperándolo, así que
|
||||||
|
// llamarlo desde `setup()` —que corre en ese mismo hilo, antes de que el bucle de eventos
|
||||||
|
// empiece a atender— colgaría la app al abrir. Por eso el texto inicial se decide aquí y
|
||||||
|
// todos los repintados posteriores salen de hilos secundarios (ver `pintar_en_hilo`).
|
||||||
|
pub fn armar_menu<R: Runtime>(app: &AppHandle<R>) -> tauri::Result<(MenuItem<R>, MenuItem<R>)> {
|
||||||
|
let cfg = cargar_cfg(app);
|
||||||
|
let estado = MenuItem::with_id(app, "trk-estado", texto_estado(&cfg, "registrando"), false, None::<&str>)?;
|
||||||
|
let toggle = MenuItem::with_id(app, "trk-toggle", texto_toggle(&cfg), cfg.token.is_some(), None::<&str>)?;
|
||||||
|
app.manage(MenuState(Mutex::new(MenuUi { estado: estado.clone(), toggle: toggle.clone() })));
|
||||||
|
Ok((estado, toggle))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maneja los clics del menú del rastreador. Devuelve true si el id era nuestro.
|
||||||
|
pub fn menu_event<R: Runtime>(app: &AppHandle<R>, id: &str) -> bool {
|
||||||
|
match id {
|
||||||
|
"trk-toggle" => {
|
||||||
|
let nucleo = app.state::<NucleoState>();
|
||||||
|
let mut n = nucleo.0.lock().unwrap();
|
||||||
|
let pausado = esta_pausado(&n.cfg);
|
||||||
|
n.cfg.pausado_hasta = if pausado { None } else { Some(PAUSA_MANUAL) };
|
||||||
|
let cfg = n.cfg.clone();
|
||||||
|
drop(n);
|
||||||
|
guardar_cfg(app, &cfg);
|
||||||
|
// El clic del menú llega EN el hilo principal: repintar aquí se bloquearía a sí
|
||||||
|
// mismo. Se delega a un hilo suelto, que además responde al instante.
|
||||||
|
pintar_en_hilo(app, if esta_pausado(&cfg) { "en pausa" } else { "registrando" }, cfg);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pintar_en_hilo<R: Runtime>(app: &AppHandle<R>, estado: &str, cfg: Config) {
|
||||||
|
let h = app.clone();
|
||||||
|
let estado = estado.to_string();
|
||||||
|
thread::spawn(move || pintar_menu(&h, &estado, &cfg));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn esta_pausado(cfg: &Config) -> bool {
|
||||||
|
match cfg.pausado_hasta {
|
||||||
|
Some(h) => h == PAUSA_MANUAL || h > ahora_seg(),
|
||||||
|
None => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn texto_estado(cfg: &Config, estado: &str) -> String {
|
||||||
|
if cfg.token.is_none() {
|
||||||
|
"Rastreador: sin vincular (Ajustes → Perfil)".to_string()
|
||||||
|
} else {
|
||||||
|
format!("Rastreador: {estado}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn texto_toggle(cfg: &Config) -> &'static str {
|
||||||
|
if esta_pausado(cfg) { "Reanudar el rastreador" } else { "Pausar el rastreador" }
|
||||||
|
}
|
||||||
|
|
||||||
|
// OJO: solo desde hilos secundarios (ver `armar_menu`).
|
||||||
|
fn pintar_menu<R: Runtime>(app: &AppHandle<R>, estado: &str, cfg: &Config) {
|
||||||
|
let Some(menu) = app.try_state::<MenuState<R>>() else { return };
|
||||||
|
let ui = menu.0.lock().unwrap();
|
||||||
|
let _ = ui.estado.set_text(texto_estado(cfg, estado));
|
||||||
|
let _ = ui.toggle.set_text(texto_toggle(cfg));
|
||||||
|
let _ = ui.toggle.set_enabled(cfg.token.is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Normalización ──
|
||||||
|
fn normaliza(s: &str, max: usize) -> String {
|
||||||
|
let limpio = s.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||||
|
limpio.chars().take(max).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Envío ──
|
||||||
|
// Sube la cola entera; deja en la cola lo que no pudo. Un 401 = token revocado → se descarta
|
||||||
|
// el token (la bandeja pasa a «sin vincular») y la cola se vacía: ya nadie la quiere.
|
||||||
|
fn enviar<R: Runtime>(app: &AppHandle<R>) {
|
||||||
|
let (token, lotes) = {
|
||||||
|
let nucleo = app.state::<NucleoState>();
|
||||||
|
let n = nucleo.0.lock().unwrap();
|
||||||
|
let Some(t) = n.cfg.token.clone() else { return };
|
||||||
|
if n.cola.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(t, n.cola.clone())
|
||||||
|
};
|
||||||
|
let hostname = gethostname::gethostname().to_string_lossy().to_string();
|
||||||
|
let version = app.package_info().version.to_string();
|
||||||
|
let mut enviados = 0usize;
|
||||||
|
let mut revocado = false;
|
||||||
|
for lote in &lotes {
|
||||||
|
let r = ureq::post(API)
|
||||||
|
.set("Authorization", &format!("Bearer {token}"))
|
||||||
|
.timeout(Duration::from_secs(20))
|
||||||
|
.send_json(json!({
|
||||||
|
"device": { "hostname": hostname, "platform": std::env::consts::OS, "version": version },
|
||||||
|
"blocks": lote,
|
||||||
|
}));
|
||||||
|
match r {
|
||||||
|
Ok(_) => enviados += 1,
|
||||||
|
Err(ureq::Error::Status(401, _)) => {
|
||||||
|
revocado = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Err(_) => break, // sin red o error del servidor: se reintenta en el próximo ciclo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let nucleo = app.state::<NucleoState>();
|
||||||
|
let mut n = nucleo.0.lock().unwrap();
|
||||||
|
if revocado {
|
||||||
|
n.cfg.token = None;
|
||||||
|
n.cola.clear();
|
||||||
|
let cfg = n.cfg.clone();
|
||||||
|
drop(n);
|
||||||
|
guardar_cfg(app, &cfg);
|
||||||
|
guardar_cola(app, &[]);
|
||||||
|
pintar_menu(app, "sin vincular", &cfg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// El largo se calcula ANTES del drain: dentro del argumento sería un préstamo inmutable
|
||||||
|
// mientras `n.cola` ya está prestado mutable — a través del MutexGuard (un deref
|
||||||
|
// explícito) el two-phase borrow no lo cubre, y no compila.
|
||||||
|
let hasta = enviados.min(n.cola.len());
|
||||||
|
n.cola.drain(0..hasta);
|
||||||
|
if n.cola.len() > MAX_COLA_LOTES {
|
||||||
|
let sobra = n.cola.len() - MAX_COLA_LOTES;
|
||||||
|
n.cola.drain(0..sobra); // sin red por semanas: se suelta lo más viejo, no lo nuevo
|
||||||
|
}
|
||||||
|
let cola = n.cola.clone();
|
||||||
|
drop(n);
|
||||||
|
guardar_cola(app, &cola);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Manda un evento a la página SIN bloquear el hilo del que sale. Mismo motivo que
|
||||||
|
/// `pintar_en_hilo`: un listener puede correr en el hilo principal, y cualquier cosa que
|
||||||
|
/// espere a ese hilo desde ahí cuelga la app.
|
||||||
|
fn avisar<R: Runtime>(app: &AppHandle<R>, evento: &'static str, payload: serde_json::Value) {
|
||||||
|
let h = app.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
let _ = h.emit(evento, payload);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Arranque: listener de vinculación + hilo del sensor ──
|
||||||
|
pub fn iniciar<R: Runtime>(app: &AppHandle<R>) {
|
||||||
|
let cfg = cargar_cfg(app);
|
||||||
|
let cola = cargar_cola(app);
|
||||||
|
app.manage(NucleoState(Mutex::new(Nucleo { cfg, cola })));
|
||||||
|
// El menú ya nació con el texto correcto (armar_menu); repintarlo aquí bloquearía el
|
||||||
|
// hilo principal. De aquí en adelante lo repinta el sensor cuando cambia el estado.
|
||||||
|
|
||||||
|
// La página de Ajustes (dentro de la app) entrega el token recién generado.
|
||||||
|
let h = app.clone();
|
||||||
|
app.listen_any("ls-tracker-token", move |e| {
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct P {
|
||||||
|
token: String,
|
||||||
|
}
|
||||||
|
let Ok(p) = serde_json::from_str::<P>(e.payload()) else { return };
|
||||||
|
if !p.token.starts_with("ltk_") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let nucleo = h.state::<NucleoState>();
|
||||||
|
let cfg = {
|
||||||
|
let mut n = nucleo.0.lock().unwrap();
|
||||||
|
n.cfg.token = Some(p.token);
|
||||||
|
n.cfg.pausado_hasta = None;
|
||||||
|
n.cfg.clone()
|
||||||
|
};
|
||||||
|
guardar_cfg(&h, &cfg);
|
||||||
|
// ACUSE de recibo. Sin esto la página no puede distinguir «el sensor lo guardó» de
|
||||||
|
// «esta app es vieja y no había nadie escuchando», y cantaba éxito en falso dejando
|
||||||
|
// un equipo registrado que jamás reporta. Si no llega este evento, la página revoca.
|
||||||
|
avisar(&h, "ls-tracker-listo", json!({ "ok": true }));
|
||||||
|
// Sin repintar aquí: el evento puede llegar en el hilo principal. El sensor ve el
|
||||||
|
// token en su próximo tic (≤5 s) y actualiza la bandeja solo.
|
||||||
|
});
|
||||||
|
|
||||||
|
// La página pregunta cómo está ESTE equipo (¿ya vinculado? ¿en pausa?) para no ofrecer
|
||||||
|
// vincular lo que ya está vinculado y para poder avisar cuando falta hacerlo.
|
||||||
|
let h = app.clone();
|
||||||
|
app.listen_any("ls-tracker-consulta", move |_| {
|
||||||
|
let nucleo = h.state::<NucleoState>();
|
||||||
|
let cfg = nucleo.0.lock().unwrap().cfg.clone();
|
||||||
|
avisar(
|
||||||
|
&h,
|
||||||
|
"ls-tracker-estado",
|
||||||
|
json!({
|
||||||
|
"vinculado": cfg.token.is_some(),
|
||||||
|
"pausado": esta_pausado(&cfg),
|
||||||
|
"version": env!("CARGO_PKG_VERSION"),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// El sensor: un hilo con tic de 5 s. Nada de esto toca la interfaz salvo el menú del tray.
|
||||||
|
let h = app.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
let device_state = device_query::DeviceState::new();
|
||||||
|
let mut ultimo_input = ahora_seg();
|
||||||
|
let mut huella_anterior: (i32, i32, usize) = (0, 0, 0);
|
||||||
|
let mut acumulado: HashMap<(String, String), Bloque> = HashMap::new();
|
||||||
|
let mut ultimo_envio = ahora_seg();
|
||||||
|
let mut ultimo_estado = String::new();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
thread::sleep(Duration::from_secs(TICK_SEG));
|
||||||
|
let ahora = ahora_seg();
|
||||||
|
|
||||||
|
let (token_ok, pausado) = {
|
||||||
|
let nucleo = h.state::<NucleoState>();
|
||||||
|
let n = nucleo.0.lock().unwrap();
|
||||||
|
(n.cfg.token.is_some(), esta_pausado(&n.cfg))
|
||||||
|
};
|
||||||
|
|
||||||
|
// ¿Hubo entrada desde el último tic? Solo se compara una huella (posición del
|
||||||
|
// mouse + cuántas teclas hay presionadas): nunca se registra QUÉ se tecleó.
|
||||||
|
use device_query::DeviceQuery;
|
||||||
|
let mouse = device_state.get_mouse();
|
||||||
|
let teclas = device_state.get_keys().len();
|
||||||
|
let huella = (mouse.coords.0, mouse.coords.1, teclas);
|
||||||
|
let hubo_input = huella != huella_anterior || teclas > 0;
|
||||||
|
huella_anterior = huella;
|
||||||
|
if hubo_input {
|
||||||
|
ultimo_input = ahora;
|
||||||
|
}
|
||||||
|
let ocioso = ahora.saturating_sub(ultimo_input) >= OCIO_PROFUNDO_SEG;
|
||||||
|
|
||||||
|
let estado = if !token_ok {
|
||||||
|
"sin vincular"
|
||||||
|
} else if pausado {
|
||||||
|
"en pausa"
|
||||||
|
} else if ocioso {
|
||||||
|
"inactivo (no cuenta)"
|
||||||
|
} else {
|
||||||
|
"registrando"
|
||||||
|
};
|
||||||
|
if estado != ultimo_estado {
|
||||||
|
let cfg = {
|
||||||
|
let nucleo = h.state::<NucleoState>();
|
||||||
|
let n = nucleo.0.lock().unwrap();
|
||||||
|
n.cfg.clone()
|
||||||
|
};
|
||||||
|
pintar_menu(&h, estado, &cfg);
|
||||||
|
ultimo_estado = estado.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
if token_ok && !pausado && !ocioso {
|
||||||
|
if let Ok(v) = active_win_pos_rs::get_active_window() {
|
||||||
|
let app_name = normaliza(&v.app_name, 80);
|
||||||
|
let titulo = normaliza(&v.title, 140);
|
||||||
|
if !app_name.is_empty() {
|
||||||
|
let b = acumulado.entry((app_name.clone(), titulo.clone())).or_insert_with(|| Bloque {
|
||||||
|
s: ahora_ms(),
|
||||||
|
d: 0,
|
||||||
|
a: 0,
|
||||||
|
app: app_name,
|
||||||
|
t: titulo,
|
||||||
|
});
|
||||||
|
b.d += TICK_SEG as u32;
|
||||||
|
if hubo_input {
|
||||||
|
b.a += TICK_SEG as u32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cada 5 min: el acumulado pasa a la cola y se intenta subir todo.
|
||||||
|
if ahora.saturating_sub(ultimo_envio) >= LOTE_SEG {
|
||||||
|
ultimo_envio = ahora;
|
||||||
|
if !acumulado.is_empty() {
|
||||||
|
let lote: Vec<Bloque> = acumulado.drain().map(|(_, b)| b).collect();
|
||||||
|
let nucleo = h.state::<NucleoState>();
|
||||||
|
let cola = {
|
||||||
|
let mut n = nucleo.0.lock().unwrap();
|
||||||
|
n.cola.push(lote);
|
||||||
|
n.cola.clone()
|
||||||
|
};
|
||||||
|
guardar_cola(&h, &cola);
|
||||||
|
}
|
||||||
|
enviar(&h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Labstream OS",
|
"productName": "Labstream OS",
|
||||||
"version": "1.4.2",
|
"version": "1.8.0",
|
||||||
"identifier": "co.labstream.os",
|
"identifier": "co.labstream.os",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../dist"
|
"frontendDist": "../dist"
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user