mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 16:38:31 +00:00
- HP-1520-01: the glow layer is hidden in the plan editor, but the yellow suppression still fired there — a lit lamp had NEITHER indicator. The gate now equals the layer's visibility (disp.fill === 'glow' && !this._markup), so the badge returns exactly where the spot is absent. - HP-1513-01: the static card ignored marker.size and marker.angle — the same stored marker looked different on the two cards. It mirrors --dev-scale and the icon rotation now; geometry only, no live dressing. - HP-1520-02: TESTING/UX-MODES still demanded the removed RGB icon tint, and the lightC comment described the old use. All three brought to the v1.52.0 contract. smoke_light_badges grew the editor-mode vectors; new smoke_size_angle_parity asserts the x3 ratio inside each card (absolute px are incomparable across containers) and rotation on both. Inventory: 147 / 51 / 43 / 71.
62 lines
3.6 KiB
JavaScript
62 lines
3.6 KiB
JavaScript
// HP-1513-01: один и тот же маркер (size 3, angle 37) обязан выглядеть
|
|
// одинаково на полной и статичной карточках — статичная игнорировала и
|
|
// множитель размера, и поворот.
|
|
import { launch, checkAll, finish } from './serve.mjs';
|
|
const { page, browser } = await launch({ width: 900, height: 900 }, 1);
|
|
const out = await page.evaluate(async () => {
|
|
const o = {};
|
|
const c = window.__card;
|
|
await customElements.whenDefined('houseplan-space-card');
|
|
const d = c._devices.find((x) => x.space === 'f1' && x.bindingKind === 'device');
|
|
const cfg = JSON.parse(JSON.stringify(c._serverCfg));
|
|
cfg.markers = (cfg.markers || []).filter((m) => m.id !== d.id);
|
|
cfg.markers.push({ id: d.id, binding: 'device:' + d.bindingRef, size: 3, angle: 37 });
|
|
c._serverCfg = cfg; c._cfgEpoch++; c._regSignature = '';
|
|
c._maybeRebuildDevices(); c.requestUpdate(); await c.updateComplete;
|
|
await new Promise((r) => setTimeout(r, 100));
|
|
const pick = (root) => [...root.querySelectorAll('.dev')]
|
|
.find((e) => (e.getAttribute('style') || '').includes('--dev-scale:3'));
|
|
const full = pick(c.shadowRoot || c.renderRoot);
|
|
const fW = full?.getBoundingClientRect().width || 0;
|
|
const fT = full ? getComputedStyle(full.querySelector('ha-icon')).transform : 'none';
|
|
|
|
window.__hpInvalidate?.();
|
|
const hass = { ...c.hass, callWS: async (m) => {
|
|
if (m.type === 'houseplan/config/get') return { config: cfg, rev: 83 };
|
|
if (m.type === 'houseplan/layout/get') return { layout: c._layout, rev: 83 };
|
|
return { ok: true };
|
|
}, connection: { subscribeEvents: async (cb) => { window.__hpInvalidate = cb; return () => {}; } } };
|
|
const host = document.createElement('div');
|
|
document.body.appendChild(host);
|
|
const card = document.createElement('houseplan-space-card');
|
|
card.setConfig({ type: 'custom:houseplan-space-card', space: 'f1' });
|
|
card.hass = hass;
|
|
host.appendChild(card);
|
|
const t0 = Date.now();
|
|
while (!pick(card.renderRoot || { querySelectorAll: () => [] }) && Date.now() - t0 < 6000) {
|
|
await new Promise((r) => setTimeout(r, 60));
|
|
}
|
|
const st = pick(card.renderRoot);
|
|
const sW = st?.getBoundingClientRect().width || 0;
|
|
const sT = st ? getComputedStyle(st.querySelector('ha-icon')).transform : 'none';
|
|
o.staticCarriesScale = sW > 0;
|
|
// абсолютные px несравнимы (разные контейнеры/letterbox) — контракт в том,
|
|
// что множитель РАБОТАЕТ на обеих карточках: базовый значок той же карточки
|
|
// втрое меньше масштабированного
|
|
const stBase = [...card.renderRoot.querySelectorAll('.dev')]
|
|
.find((e) => !(e.getAttribute('style') || '').includes('--dev-scale'));
|
|
const sBaseW = stBase?.getBoundingClientRect().width || 0;
|
|
o.staticRatioIs3 = sBaseW > 0 && Math.abs(sW / sBaseW - 3) < 0.35;
|
|
const fBase = [...(c.shadowRoot || c.renderRoot).querySelectorAll('.dev')]
|
|
.find((e) => !(e.getAttribute('style') || '').includes('--dev-scale') && !e.classList.contains('ghost'));
|
|
const fBaseW = fBase?.getBoundingClientRect().width || 0;
|
|
o.fullRatioIs3 = fBaseW > 0 && Math.abs(fW / fBaseW - 3) < 0.35;
|
|
o.bothRotated = fT !== 'none' && sT !== 'none' && fT.startsWith('matrix') && sT.startsWith('matrix');
|
|
if (!o.staticRatioIs3) console.log('static', sW, sBaseW);
|
|
host.remove();
|
|
c._serverCfg.markers = c._serverCfg.markers.filter((m) => m.id !== d.id);
|
|
c._cfgEpoch++; c._regSignature = ''; c._maybeRebuildDevices();
|
|
return o;
|
|
});
|
|
await finish(browser, checkAll(out));
|