@legios/quartermaster 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +281 -8
- package/bin/qm-barra.swift +48 -1
- package/bin/qm-indicator +23 -1
- package/bin/qm-tray.ps1 +1252 -252
- package/dist/cli/qm.js +38 -0
- package/dist/cli/qm.js.map +1 -1
- package/dist/core/presupuesto.js +75 -0
- package/dist/core/presupuesto.js.map +1 -0
- package/dist/render/tablero.html +68 -6
- package/package.json +3 -2
- package/scripts/gate-bandeja.ps1 +172 -0
- package/scripts/gate-dibujo.sh +49 -0
- package/src/render/tablero.html +68 -6
package/scripts/gate-dibujo.sh
CHANGED
|
@@ -40,6 +40,55 @@ python3 -c "import py_compile,sys; py_compile.compile(sys.argv[1], cfile=sys.arg
|
|
|
40
40
|
cp -f "extension/quartermaster@legios/extension.js" "$salida/ext.mjs"
|
|
41
41
|
node --check "$salida/ext.mjs" || fallar "extension.js no parsea"
|
|
42
42
|
|
|
43
|
+
# Y la bandeja de Windows, que es la superficie que más tiempo estuvo sin que la
|
|
44
|
+
# mirara nadie: de sus ~1500 líneas el CI comprobaba UNA función. Acá sólo se
|
|
45
|
+
# parsea —dibujar necesita System.Drawing, que es de Windows, y eso lo hace
|
|
46
|
+
# scripts/gate-bandeja.ps1 en el runner de Windows—, pero parsear ya es lo más
|
|
47
|
+
# barato de romper y lo más caro de descubrir: un error de sintaxis se ve recién
|
|
48
|
+
# cuando alguien inicia sesión.
|
|
49
|
+
if command -v pwsh >/dev/null 2>&1; then
|
|
50
|
+
pwsh -NoProfile -Command '
|
|
51
|
+
$e = $null
|
|
52
|
+
[System.Management.Automation.Language.Parser]::ParseFile(
|
|
53
|
+
(Resolve-Path bin/qm-tray.ps1), [ref]$null, [ref]$e) | Out-Null
|
|
54
|
+
if ($e -and $e.Count) {
|
|
55
|
+
$e | Select-Object -First 5 | ForEach-Object {
|
|
56
|
+
[Console]::Error.WriteLine(" línea $($_.Extent.StartLineNumber): $($_.Message)") }
|
|
57
|
+
exit 1
|
|
58
|
+
}' || fallar "bin/qm-tray.ps1 no parsea"
|
|
59
|
+
echo "bandeja: bin/qm-tray.ps1 parsea"
|
|
60
|
+
elif [ -n "$QM_GATE_EXIGE_PWSH" ]; then
|
|
61
|
+
fallar "falta pwsh y este job lo exige"
|
|
62
|
+
else
|
|
63
|
+
echo " · salteada: la bandeja de Windows (no hay pwsh en esta máquina)"
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# Y la barra de menú de macOS, que era el ÚNICO fuente del repo que no abría
|
|
67
|
+
# ningún gate: gate-duraciones.py le extrae una función y compila esa sola, así
|
|
68
|
+
# que el resto del archivo podía tener un error de sintaxis y el CI no se
|
|
69
|
+
# enteraba. Es el mismo agujero que tenían el indicador de GNOME y la bandeja de
|
|
70
|
+
# Windows, contado dos veces en este archivo.
|
|
71
|
+
#
|
|
72
|
+
# AppKit es de macOS, pero `swiftc -parse` sólo PARSEA: no carga módulos ni
|
|
73
|
+
# chequea tipos, así que el error más barato de cometer —y el más caro de
|
|
74
|
+
# descubrir, porque hoy se ve recién cuando alguien compila en una Mac— se
|
|
75
|
+
# agarra desde Ubuntu. Si este swiftc igual no puede, lo dice y se saltea: nunca
|
|
76
|
+
# se da por bueno en silencio.
|
|
77
|
+
if command -v swiftc >/dev/null 2>&1; then
|
|
78
|
+
if swift_salida=$(swiftc -parse bin/qm-barra.swift 2>&1); then
|
|
79
|
+
echo "barra de macOS: bin/qm-barra.swift parsea"
|
|
80
|
+
elif echo "$swift_salida" | grep -qi "no such module"; then
|
|
81
|
+
echo " · salteada: la barra de macOS (este swiftc no parsea sin AppKit)"
|
|
82
|
+
else
|
|
83
|
+
echo "$swift_salida" | head -5 >&2
|
|
84
|
+
fallar "bin/qm-barra.swift no parsea"
|
|
85
|
+
fi
|
|
86
|
+
elif [ -n "$QM_GATE_EXIGE_SWIFT" ]; then
|
|
87
|
+
fallar "falta swiftc y este job lo exige"
|
|
88
|
+
else
|
|
89
|
+
echo " · salteada: la barra de macOS (no hay swiftc en esta máquina)"
|
|
90
|
+
fi
|
|
91
|
+
|
|
43
92
|
python3 bin/qm-indicator --desde test/fixtures/panel.json --oscuro \
|
|
44
93
|
--captura "$salida/panel.png" >/dev/null || fallar "no dibujó el panel"
|
|
45
94
|
python3 bin/qm-indicator --desde test/fixtures/panel.json --oscuro \
|
package/src/render/tablero.html
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>quartermaster</title>
|
|
7
|
+
<!-- El mismo medidor al que le falta un cuarto que es docs/favicon.svg, acá
|
|
8
|
+
adentro: qm-web sirve UN archivo y nada más, así que un <link> a un .svg
|
|
9
|
+
del repo daría 404 en toda instalación que no sea el clon. -->
|
|
10
|
+
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><defs><linearGradient id='qm' gradientUnits='userSpaceOnUse' x1='14' y1='46' x2='50' y2='14'><stop offset='0' stop-color='%232fbf71'/><stop offset='.5' stop-color='%23f2b134'/><stop offset='1' stop-color='%23e2483d'/></linearGradient></defs><path d='M32 11A21 21 0 1 1 13.9 43' fill='none' stroke='url(%23qm)' stroke-width='11' stroke-linecap='round'/><path d='M41 41 52 52' fill='none' stroke='url(%23qm)' stroke-width='11' stroke-linecap='round'/></svg>">
|
|
7
11
|
<style>
|
|
8
12
|
/* ── Tokens ───────────────────────────────────────────────────────────────
|
|
9
13
|
Paleta de estado fija (good/warning/serious/critical): el color nunca va
|
|
@@ -73,10 +77,8 @@ header.barra {
|
|
|
73
77
|
padding: 28px 0 20px; border-bottom: 1px solid var(--linea); margin-bottom: 28px;
|
|
74
78
|
}
|
|
75
79
|
.marca { font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
|
|
76
|
-
.marca
|
|
77
|
-
|
|
78
|
-
background: var(--acento); margin-right: 8px; vertical-align: 1px;
|
|
79
|
-
}
|
|
80
|
+
.marca { display: flex; align-items: center; gap: 8px; }
|
|
81
|
+
.marca .logo { flex: none; display: block; }
|
|
80
82
|
.lema { color: var(--tinta-3); font-size: 13px; }
|
|
81
83
|
.barra .derecha { margin-left: auto; display: flex; align-items: center; gap: 10px; }
|
|
82
84
|
.chip {
|
|
@@ -177,6 +179,25 @@ button.chip:focus-visible { outline: 2px solid var(--acento); outline-offset: 2p
|
|
|
177
179
|
color: var(--tinta-3); margin-top: 2px; }
|
|
178
180
|
.heroe .detalle .choque { color: var(--critico); font-weight: 550; }
|
|
179
181
|
|
|
182
|
+
/* ── Presupuesto diario ───────────────────────────────────────────────── */
|
|
183
|
+
.presupuesto {
|
|
184
|
+
display: flex; align-items: baseline; gap: 6px 18px; flex-wrap: wrap;
|
|
185
|
+
border-top: 1px solid var(--linea); padding-top: 11px; font-size: 12.5px;
|
|
186
|
+
color: var(--tinta-2);
|
|
187
|
+
}
|
|
188
|
+
.presupuesto .par { display: inline-flex; align-items: baseline; gap: 6px; }
|
|
189
|
+
.presupuesto .k {
|
|
190
|
+
font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
|
|
191
|
+
color: var(--tinta-3); font-weight: 600;
|
|
192
|
+
}
|
|
193
|
+
.presupuesto .v {
|
|
194
|
+
font-size: 15px; font-weight: 640; color: var(--tinta);
|
|
195
|
+
font-variant-numeric: tabular-nums; letter-spacing: -0.015em;
|
|
196
|
+
}
|
|
197
|
+
.presupuesto .ventana { color: var(--tinta-3); }
|
|
198
|
+
.presupuesto .motivo { color: var(--tinta-3); }
|
|
199
|
+
.heroe .presupuesto { border-top: none; padding-top: 12px; }
|
|
200
|
+
|
|
180
201
|
/* ── Frase: todo estado sin número produce una oración ────────────────── */
|
|
181
202
|
.frase {
|
|
182
203
|
font-size: 13px; color: var(--tinta-2); background: var(--sup-2);
|
|
@@ -239,7 +260,15 @@ td.num { text-align: right; font-variant-numeric: tabular-nums; }
|
|
|
239
260
|
<div class="envoltorio">
|
|
240
261
|
<header class="barra">
|
|
241
262
|
<div>
|
|
242
|
-
<div class="marca"
|
|
263
|
+
<div class="marca">
|
|
264
|
+
<svg class="logo" viewBox="0 0 64 64" width="18" height="18" aria-hidden="true">
|
|
265
|
+
<defs><linearGradient id="grad-qm" gradientUnits="userSpaceOnUse" x1="14" y1="46" x2="50" y2="14">
|
|
266
|
+
<stop offset="0" stop-color="#2fbf71"/><stop offset=".5" stop-color="#f2b134"/><stop offset="1" stop-color="#e2483d"/>
|
|
267
|
+
</linearGradient></defs>
|
|
268
|
+
<circle cx="32" cy="32" r="20" fill="none" stroke="currentColor" stroke-opacity=".14" stroke-width="9"/>
|
|
269
|
+
<path d="M32 12A20 20 0 1 1 14.8 42" fill="none" stroke="url(#grad-qm)" stroke-width="9" stroke-linecap="round"/>
|
|
270
|
+
<path d="M41 41 51.5 51.5" fill="none" stroke="url(#grad-qm)" stroke-width="9" stroke-linecap="round"/>
|
|
271
|
+
</svg>quartermaster</div>
|
|
243
272
|
<div class="lema">Cuánta cuota te queda, en todas tus cuentas de agentes.</div>
|
|
244
273
|
</div>
|
|
245
274
|
<div class="derecha">
|
|
@@ -447,6 +476,37 @@ function curva(historia, nivel) {
|
|
|
447
476
|
</div>`;
|
|
448
477
|
}
|
|
449
478
|
|
|
479
|
+
// ── presupuesto diario ─────────────────────────────────────────────────
|
|
480
|
+
// «vas 78 %» no dice si mañana hay que frenar. Repartir lo que queda entre los
|
|
481
|
+
// días que faltan sí, y eso llega masticado del núcleo: qué ventana se reparte
|
|
482
|
+
// —la larga, nunca la de 5 h—, cuánto por día y cuánto de eso queda hoy. Acá no
|
|
483
|
+
// se divide nada, igual que con `frena` y `semanal`.
|
|
484
|
+
const unDecimal = (n) => Number(n).toFixed(1).replace('.', ',');
|
|
485
|
+
|
|
486
|
+
function presupuesto(pre) {
|
|
487
|
+
if (!pre) return '';
|
|
488
|
+
if (pre.estado !== 'ok') {
|
|
489
|
+
return `<div class="presupuesto">
|
|
490
|
+
<span class="k">presupuesto diario</span>
|
|
491
|
+
<span class="motivo">${esc(pre.motivo)}</span>
|
|
492
|
+
</div>`;
|
|
493
|
+
}
|
|
494
|
+
const tip = esc(JSON.stringify({
|
|
495
|
+
t: 'presupuesto diario · ' + pre.barra,
|
|
496
|
+
l: [
|
|
497
|
+
`queda ${unDecimal(pre.restante)} % de la ventana y faltan ${unDecimal(pre.horasRestantes / 24)} días para el reinicio`,
|
|
498
|
+
`gastando ${unDecimal(pre.porDia)} % por día llegás justo al reinicio con la cuota consumida`,
|
|
499
|
+
`hoy le quedan ${unDecimal(pre.horasHoy)} h: de ahí sale el ${unDecimal(pre.quedaHoy)} % que te queda hoy`,
|
|
500
|
+
'se recalcula en cada lectura: si hoy gastaste de más, el ritmo baja solo',
|
|
501
|
+
],
|
|
502
|
+
}));
|
|
503
|
+
return `<div class="presupuesto" data-tip='${tip}'>
|
|
504
|
+
<span class="par"><span class="k">podés gastar</span><span class="v">${unDecimal(pre.porDia)} %/día</span></span>
|
|
505
|
+
<span class="par"><span class="k">te queda hoy</span><span class="v">${unDecimal(pre.quedaHoy)} %</span></span>
|
|
506
|
+
<span class="ventana">${esc(pre.barra)}</span>
|
|
507
|
+
</div>`;
|
|
508
|
+
}
|
|
509
|
+
|
|
450
510
|
function desglose(porModelo) {
|
|
451
511
|
const pares = Object.entries(porModelo).filter(([, v]) => v > 0).sort((a, b) => b[1] - a[1]);
|
|
452
512
|
if (!pares.length) return '';
|
|
@@ -482,7 +542,8 @@ function tarjeta(p) {
|
|
|
482
542
|
? `<div class="medidores">${vs.map(v => medidor(v, proy, proyectada !== null && v.clave === proyectada.clave)).join('')}</div>` +
|
|
483
543
|
(p.proyeccion && p.proyeccion.estado !== 'sube'
|
|
484
544
|
? `<div class="frase">ritmo: ${p.proyeccion.estado === 'plano'
|
|
485
|
-
? 'plano, no sube' : 'todavía no sé el ritmo — ' + esc(p.proyeccion.motivo)}</div>` : '')
|
|
545
|
+
? 'plano, no sube' : 'todavía no sé el ritmo — ' + esc(p.proyeccion.motivo)}</div>` : '') +
|
|
546
|
+
presupuesto(p.presupuesto)
|
|
486
547
|
: `<div class="frase">${esc(c.frase)}</div>`;
|
|
487
548
|
|
|
488
549
|
return `
|
|
@@ -560,6 +621,7 @@ function heroe() {
|
|
|
560
621
|
${proy ? `<span class="sep">·</span><span class="${proy.chocasAntesDelReinicio ? 'choque' : ''}">${esc(fraseProy(proy))}</span>` : ''}
|
|
561
622
|
</div>
|
|
562
623
|
${curva(p.cuota.historia, n)}
|
|
624
|
+
${p.presupuesto && p.presupuesto.estado === 'ok' ? presupuesto(p.presupuesto) : ''}
|
|
563
625
|
</div>
|
|
564
626
|
</div>`;
|
|
565
627
|
}
|