| 55 | // the computed --polli-color-app-bg token — never a hardcoded value. Runs on |
| 56 | // mount / mode change, after styles load, so the token resolves per mode. |
| 57 | function syncThemeColor(): void { |
| 58 | if (typeof document === "undefined") return; |
| 59 | const appBg = getComputedStyle(document.documentElement) |
| 60 | .getPropertyValue("--polli-color-app-bg") |
| 61 | .trim(); |
| 62 | if (!appBg) return; |
| 63 | let meta = document.querySelector('meta[name="theme-color"]'); |
| 64 | if (!meta) { |
| 65 | meta = document.createElement("meta"); |
| 66 | meta.setAttribute("name", "theme-color"); |
| 67 | document.head.appendChild(meta); |
| 68 | } |
| 69 | meta.setAttribute("content", appBg); |
| 70 | } |
| 71 | |
| 72 | function emit(): void { |
| 73 | for (const listener of listeners) listener(); |