Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
v0.9.14: move second-screen permission out of present into the editor's Slide panel
nyblnet74a9f2831912
diff --git a/CLAUDE.md b/CLAUDE.mdindex 16c205d5..bfa343c1 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -222,13 +222,16 @@ One HTML file = the document + viewer + editor. See `README.md` for the vision.real fullscreen makes the browser leave fullscreen, whose `fullscreenchange`would call `exit()` and END the show — `openingSpeaker` guards onFsChange andre-enters fullscreen. Escape stays a separate exit path, so the guard can't- strand the presenter. **Dual-screen (v0.9.8)**: `placeSpeaker` opens the popup- synchronously (keeps the click gesture, avoids a popup-block), then async- `getScreenDetails()` (Window Management permission) moves it to a second- display and fullscreens the slides on the presenter's screen via- `requestFullscreen({screen})`. Single-screen / denied / unsupported all- degrade to the same-screen re-fullscreen path. Needs a real two-monitor rig- for final QA.+ strand the presenter. **Dual-screen (v0.9.14)**: the Window Management+ permission CANNOT be requested during present — the S keypress activation is+ spent on window.open/requestFullscreen. So `src/screens.ts` holds the shared+ layout and the **editor's Slide panel** ("Presenter display" section) grants+ it via a dedicated click BEFORE presenting (`grantScreens`), caching the live+ ScreenDetails; the editor also `refreshScreensIfGranted()` at boot. present.ts+ `openSpeaker` reads `secondScreen()` synchronously and opens the notes popup+ directly on that display's coords; if none is set up it drops fullscreen so+ the notes aren't hidden. (The old in-present grant pill was removed.) Needs a+ real two-monitor rig for final QA.- **Animation robustness**: slide exit kills tweens AND restores model frames; a2.8s wall-clock settle guarantee lands entrances on starved render loops; neverput entrance tweens on motion-path elements (transform conflict).diff --git a/slides/package.json b/slides/package.jsonindex 6d96cd6f..f374719e 100644--- a/slides/package.json+++ b/slides/package.json@@ -1,7 +1,7 @@{"name": "bento-slides","private": true,- "version": "0.9.13",+ "version": "0.9.14","type": "module","scripts": {"dev": "vite",diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.tsindex 68c3169a..598f90dc 100644--- a/slides/src/editor/editor.ts+++ b/slides/src/editor/editor.ts@@ -17,6 +17,7 @@ import { startPresentation } from '../present'import { hasFileHandle, isEncryptionActive, saveFile, serializeAuto, serializeFile, setEncryptionPassword, writeUpdatedFile, writeUpdatedFileAs } from '../save'import { addVersion, clearRecovery, docContentKey, getRecovery, listVersions, pruneOld, putRecovery, type Snapshot } from '../autosave'import { insertElements, insertSlides, parseClip, serializeElements, serializeSlides } from './clipboard'+import { refreshScreensIfGranted } from '../screens'import { ICONS } from '../icons'import { t, setLocale, locale, LOCALE_CHOICES } from '../i18n'import { disconnectOnline, joinFromDoc, mintCollab, onlineTransport, rotateKeys, sharingOn, startSharing, stopSharing } from '../sync/online'@@ -66,6 +67,7 @@ export class Editor {})this.wireAutosave()this.wirePaste()+ void refreshScreensIfGranted() // re-enable 2nd-screen notes if granted earlierstore.on('doc', () => this.syncLinkedCharts())document.addEventListener('bento:apply-layout', ((ev: CustomEvent) => {this.openLayoutPicker(ev.detail.anchor as HTMLElement, { kind: 'apply' })diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.tsindex 7d2d99c4..afebaa42 100644--- a/slides/src/editor/panels.ts+++ b/slides/src/editor/panels.ts@@ -4,6 +4,7 @@import type { Store } from '../store'import { applyChartPalette, defaultChart, uid, type ChartElement, type LineEnding, type ShapeElement, type Slide, type SlideElement, type TableElement, type TextElement, type TransitionKind } from '../model'+import { grantScreens, screensCached, secondScreen, windowManagementSupported } from '../screens'import { CHART_PRESETS } from '../charts'import { FONT_CHOICES, firstFamily, injectFonts } from '../fonts'import { ICONS } from '../icons'@@ -126,6 +127,43 @@ export class PropsPanel {'A4 portrait': { w: 794, h: 1123 },}+ /**+ * Presenter display: grant Window Management here (a dedicated click) so a+ * live show can put speaker notes on a second screen. It CANNOT be requested+ * during present — the S keypress activation is spent on window.open /+ * fullscreen — so this is where it belongs: in the panel, before you present.+ */+ private buildPresenterDisplay() {+ if (!windowManagementSupported()) return+ this.section(t('Presenter display'))+ const btn = document.createElement('button')+ btn.className = 'ed-btn ed-btn-block'+ const status = document.createElement('p')+ status.className = 'ed-hint'+ const set = (label: string, msg: string, done: boolean) => {+ btn.textContent = label+ btn.disabled = done+ btn.classList.toggle('ed-btn-primary', !done)+ status.textContent = msg+ }+ const ready = () => set(t('✓ Second screen enabled'), t('Speaker notes will open on your second display when you press S.'), true)+ const oneScreen = () => set(t('Use a second screen for notes'), t('Only one display detected — connect another, then enable it here.'), false)+ if (screensCached()) { secondScreen() ? ready() : oneScreen() } else {+ set(t('Use a second screen for notes'), t('Enable this once so pressing S in a show sends notes to your other display.'), false)+ }+ btn.addEventListener('click', async () => {+ const prev = btn.textContent+ btn.textContent = t('Requesting…')+ const r = await grantScreens()+ if (r.ok && r.screens > 1) ready()+ else if (r.ok) oneScreen()+ else { set(prev ?? t('Use a second screen for notes'), t('Couldn’t access displays — allow “window management” in the browser’s site permissions.'), false) }+ })+ const wrap = document.createElement('div')+ wrap.append(btn, status)+ this.host.appendChild(wrap)+ }+private buildSlidePanel() {const slide = this.store.slidethis.section(t('Slide'))@@ -163,6 +201,8 @@ export class PropsPanel {this.host.appendChild(hint)}+ this.buildPresenterDisplay()+// interactivity: naming, state-of, hover focusthis.section(t('Interactivity'))const name = document.createElement('input')diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.tsindex fdcfbad0..656f4c97 100644--- a/slides/src/i18n/de.ts+++ b/slides/src/i18n/de.ts@@ -419,4 +419,12 @@ export const de: Catalog = {"Second screen ready — press S for speaker notes": "Zweiter Bildschirm bereit — S für die Referentenansicht","Only one screen detected — notes will open in a window (S)": "Nur ein Bildschirm erkannt — Notizen öffnen in einem Fenster (S)","Couldn’t access displays — notes will open in a window (S)": "Kein Zugriff auf Bildschirme — Notizen öffnen in einem Fenster (S)",+ "Presenter display": "Referentenanzeige",+ "✓ Second screen enabled": "✓ Zweiter Bildschirm aktiviert",+ "Speaker notes will open on your second display when you press S.": "Referentennotizen öffnen auf dem zweiten Bildschirm, wenn du S drückst.",+ "Use a second screen for notes": "Zweiten Bildschirm für Notizen nutzen",+ "Only one display detected — connect another, then enable it here.": "Nur ein Bildschirm erkannt — schließe einen weiteren an und aktiviere ihn hier.",+ "Enable this once so pressing S in a show sends notes to your other display.": "Einmal aktivieren, damit S in einer Präsentation die Notizen auf den anderen Bildschirm sendet.",+ "Requesting…": "Anfrage läuft…",+ "Couldn’t access displays — allow “window management” in the browser’s site permissions.": "Kein Zugriff auf Bildschirme — erlaube „Fensterverwaltung“ in den Website-Berechtigungen des Browsers.",}diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.tsindex 702ef4a1..e7bad625 100644--- a/slides/src/i18n/es.ts+++ b/slides/src/i18n/es.ts@@ -419,4 +419,12 @@ export const es: Catalog = {"Second screen ready — press S for speaker notes": "Segunda pantalla lista — pulsa S para las notas del ponente","Only one screen detected — notes will open in a window (S)": "Solo se detectó una pantalla — las notas se abrirán en una ventana (S)","Couldn’t access displays — notes will open in a window (S)": "No se pudo acceder a las pantallas — las notas se abrirán en una ventana (S)",+ "Presenter display": "Pantalla del ponente",+ "✓ Second screen enabled": "✓ Segunda pantalla activada",+ "Speaker notes will open on your second display when you press S.": "Las notas del ponente se abrirán en tu segunda pantalla al pulsar S.",+ "Use a second screen for notes": "Usar una segunda pantalla para las notas",+ "Only one display detected — connect another, then enable it here.": "Solo se detectó una pantalla — conecta otra y actívala aquí.",+ "Enable this once so pressing S in a show sends notes to your other display.": "Actívalo una vez para que al pulsar S en una presentación las notas vayan a tu otra pantalla.",+ "Requesting…": "Solicitando…",+ "Couldn’t access displays — allow “window management” in the browser’s site permissions.": "No se pudo acceder a las pantallas — permite «gestión de ventanas» en los permisos del sitio del navegador.",}diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.tsindex e14edce2..5601179a 100644--- a/slides/src/i18n/fr.ts+++ b/slides/src/i18n/fr.ts@@ -419,4 +419,12 @@ export const fr: Catalog = {"Second screen ready — press S for speaker notes": "Second écran prêt — appuyez sur S pour les notes du présentateur","Only one screen detected — notes will open in a window (S)": "Un seul écran détecté — les notes s’ouvriront dans une fenêtre (S)","Couldn’t access displays — notes will open in a window (S)": "Impossible d’accéder aux écrans — les notes s’ouvriront dans une fenêtre (S)",+ "Presenter display": "Affichage présentateur",+ "✓ Second screen enabled": "✓ Second écran activé",+ "Speaker notes will open on your second display when you press S.": "Les notes du présentateur s’ouvriront sur votre second écran en appuyant sur S.",+ "Use a second screen for notes": "Utiliser un second écran pour les notes",+ "Only one display detected — connect another, then enable it here.": "Un seul écran détecté — connectez-en un autre, puis activez-le ici.",+ "Enable this once so pressing S in a show sends notes to your other display.": "Activez-le une fois pour qu’appuyer sur S pendant une présentation envoie les notes sur votre autre écran.",+ "Requesting…": "Demande en cours…",+ "Couldn’t access displays — allow “window management” in the browser’s site permissions.": "Impossible d’accéder aux écrans — autorisez la « gestion des fenêtres » dans les permissions du site.",}diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.tsindex 3c2faaf1..0cfe6c58 100644--- a/slides/src/i18n/it.ts+++ b/slides/src/i18n/it.ts@@ -419,4 +419,12 @@ export const it: Catalog = {"Second screen ready — press S for speaker notes": "Secondo schermo pronto — premi S per le note del relatore","Only one screen detected — notes will open in a window (S)": "Rilevato un solo schermo — le note si apriranno in una finestra (S)","Couldn’t access displays — notes will open in a window (S)": "Impossibile accedere agli schermi — le note si apriranno in una finestra (S)",+ "Presenter display": "Schermo del relatore",+ "✓ Second screen enabled": "✓ Secondo schermo attivato",+ "Speaker notes will open on your second display when you press S.": "Le note del relatore si apriranno sul secondo schermo premendo S.",+ "Use a second screen for notes": "Usa un secondo schermo per le note",+ "Only one display detected — connect another, then enable it here.": "Rilevato un solo schermo — collegane un altro e abilitalo qui.",+ "Enable this once so pressing S in a show sends notes to your other display.": "Abilitalo una volta così premendo S durante una presentazione le note vanno sull’altro schermo.",+ "Requesting…": "Richiesta in corso…",+ "Couldn’t access displays — allow “window management” in the browser’s site permissions.": "Impossibile accedere agli schermi — consenti la «gestione finestre» nei permessi del sito.",}diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.tsindex 245b4dec..27252491 100644--- a/slides/src/i18n/ja.ts+++ b/slides/src/i18n/ja.ts@@ -419,4 +419,12 @@ export const ja: Catalog = {"Second screen ready — press S for speaker notes": "2台目の画面が準備できました — S で発表者ノート","Only one screen detected — notes will open in a window (S)": "画面は1台のみ — ノートはウィンドウで開きます(S)","Couldn’t access displays — notes will open in a window (S)": "ディスプレイにアクセスできません — ノートはウィンドウで開きます(S)",+ "Presenter display": "発表者ディスプレイ",+ "✓ Second screen enabled": "✓ 2台目の画面を有効化",+ "Speaker notes will open on your second display when you press S.": "S を押すと発表者ノートが2台目の画面に開きます。",+ "Use a second screen for notes": "ノートに2台目の画面を使う",+ "Only one display detected — connect another, then enable it here.": "画面は1台のみ — もう1台接続してここで有効化してください。",+ "Enable this once so pressing S in a show sends notes to your other display.": "一度有効にすれば、ショー中に S を押すとノートがもう一方の画面に表示されます。",+ "Requesting…": "要求中…",+ "Couldn’t access displays — allow “window management” in the browser’s site permissions.": "ディスプレイにアクセスできません — ブラウザーのサイト権限で「ウィンドウ管理」を許可してください。",}diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.tsindex 89012821..8aeb72c3 100644--- a/slides/src/i18n/zh-Hans.ts+++ b/slides/src/i18n/zh-Hans.ts@@ -419,4 +419,12 @@ export const zhHans: Catalog = {"Second screen ready — press S for speaker notes": "第二块屏幕已就绪 — 按 S 显示演讲者备注","Only one screen detected — notes will open in a window (S)": "仅检测到一块屏幕 — 备注将在窗口中打开(S)","Couldn’t access displays — notes will open in a window (S)": "无法访问显示器 — 备注将在窗口中打开(S)",+ "Presenter display": "演讲者显示",+ "✓ Second screen enabled": "✓ 已启用第二块屏幕",+ "Speaker notes will open on your second display when you press S.": "按 S 时演讲者备注将在第二块屏幕上打开。",+ "Use a second screen for notes": "用第二块屏幕显示备注",+ "Only one display detected — connect another, then enable it here.": "仅检测到一块屏幕 — 连接另一块后在此启用。",+ "Enable this once so pressing S in a show sends notes to your other display.": "启用一次后,放映时按 S 即可把备注发送到另一块屏幕。",+ "Requesting…": "正在请求…",+ "Couldn’t access displays — allow “window management” in the browser’s site permissions.": "无法访问显示器 — 请在浏览器的站点权限中允许“窗口管理”。",}diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.tsindex dd3a7f4d..e6d7c6da 100644--- a/slides/src/i18n/zh-Hant.ts+++ b/slides/src/i18n/zh-Hant.ts@@ -419,4 +419,12 @@ export const zhHant: Catalog = {"Second screen ready — press S for speaker notes": "第二個螢幕已就緒 — 按 S 顯示演講者備註","Only one screen detected — notes will open in a window (S)": "僅偵測到一個螢幕 — 備註將在視窗中開啟(S)","Couldn’t access displays — notes will open in a window (S)": "無法存取顯示器 — 備註將在視窗中開啟(S)",+ "Presenter display": "演講者顯示",+ "✓ Second screen enabled": "✓ 已啟用第二個螢幕",+ "Speaker notes will open on your second display when you press S.": "按 S 時演講者備註將在第二個螢幕上開啟。",+ "Use a second screen for notes": "用第二個螢幕顯示備註",+ "Only one display detected — connect another, then enable it here.": "僅偵測到一個螢幕 — 連接另一個後在此啟用。",+ "Enable this once so pressing S in a show sends notes to your other display.": "啟用一次後,放映時按 S 即可把備註傳送到另一個螢幕。",+ "Requesting…": "正在請求…",+ "Couldn’t access displays — allow “window management” in the browser’s site permissions.": "無法存取顯示器 — 請在瀏覽器的網站權限中允許「視窗管理」。",}diff --git a/slides/src/present.ts b/slides/src/present.tsindex 537e5872..f9be00dd 100644--- a/slides/src/present.ts+++ b/slides/src/present.ts@@ -8,6 +8,7 @@ import { anim, resetXform } from './anim'import { chartSnapshotSvg, mountChart } from './charts'import type { BentoDoc, GradientFill, ShapeElement, Slide, SlideElement } from './model'import { applyElementFrame, gradientLineCoords, renderSlide } from './render'+import { secondScreen } from './screens'import { t } from './i18n'const MORPH_DURATION = 0.65@@ -137,62 +138,10 @@ export function startPresentation(// browsers; this guards the fullscreenchange handler so that bounce doesn't// end the show (see onFsChange).let openingSpeaker = false- // Screen layout, cached at present-start so we can open the speaker popup- // DIRECTLY on a second display (window.open left/top) — moving it after the- // fact is what left the notes stranded behind the fullscreen slides.- let screenLayout: { screens: any[]; currentScreen: any } | null = null- let grantBtn: HTMLButtonElement | null = null- const hasWM = () => !!(window as unknown as { getScreenDetails?: unknown }).getScreenDetails- const secondScreen = () => {- const s = screenLayout- if (!s || !Array.isArray(s.screens) || s.screens.length < 2) return null- return s.screens.find((x) => x !== s.currentScreen) ?? s.screens.find((x) => !x.isPrimary) ?? s.screens[1]- }- // getScreenDetails() returns a LIVE object; we call it once (needs activation- // only to prompt) and keep it. Returns true if we now hold a layout.- const cacheScreens = async (): Promise<boolean> => {- const gsd = (window as unknown as { getScreenDetails?: () => Promise<any> }).getScreenDetails- if (!gsd) return false- try {- screenLayout = await gsd.call(window)- console.info('[bento-speaker] screens ready:', screenLayout?.screens?.length)- return true- } catch (e: any) {- console.warn('[bento-speaker] getScreenDetails failed:', e?.name, e?.message)- return false- }- }- // A dedicated-gesture button to grant "window management" — the ONLY reliable- // way, since the S keypress activation is spent on window.open/fullscreen.- const showGrantButton = () => {- if (grantBtn || !hasWM()) return- const b = document.createElement('button')- b.className = 'bento-present-grant'- b.textContent = t('📺 Use a second screen for notes')- b.addEventListener('click', async () => {- const ok = await cacheScreens() // this click IS the activation → prompts once- grantBtn?.remove(); grantBtn = null- const msg = document.createElement('div')- msg.className = 'bento-present-toast'- msg.textContent = ok && secondScreen()- ? t('Second screen ready — press S for speaker notes')- : (ok ? t('Only one screen detected — notes will open in a window (S)') : t('Couldn’t access displays — notes will open in a window (S)'))- overlay.appendChild(msg)- window.setTimeout(() => msg.remove(), 4000)- })- overlay.appendChild(b)- grantBtn = b- }- // At present-start: if we can read the layout without a prompt (permission- // already granted), cache it; otherwise offer the grant button.- const setupSecondScreen = async () => {- if (!hasWM()) return- let state = 'prompt'- try { state = (await (navigator as unknown as { permissions?: { query?: (o: unknown) => Promise<{ state: string }> } }).permissions?.query?.({ name: 'window-management' as PermissionName }))?.state ?? 'prompt' } catch { /* no query api */ }- console.info('[bento-speaker] window-management permission:', state)- if (state === 'granted' && await cacheScreens()) return- if (state !== 'denied') showGrantButton()- }+ // Second-screen placement is set up in the EDITOR (properties panel) before+ // presenting — that's where the Window Management permission is granted via a+ // dedicated gesture, and the layout is cached in ../screens. Here we just read+ // the chosen display synchronously when the notes open.const nextVisibleIndex = (from: number) => {for (let i = (isState(from) ? anchorOf(from) : from) + 1; i < doc.slides.length; i++) {if (!isState(i)) return i@@ -289,12 +238,12 @@ export function startPresentation(// re-enter here). Nothing to do — the good path.console.info('[bento-speaker] notes on 2nd screen; slides', document.fullscreenElement ? 'still fullscreen' : '→ press F for fullscreen')} else if (wasFullscreen) {- // No second-screen placement (permission not granted / single screen) —- // the notes would sit hidden behind the fullscreen slides. Drop fullscreen- // so they're visible, and surface the one-click grant button.- console.info('[bento-speaker] no 2nd screen — revealing notes; offering the grant button')+ // No second display set up — the notes would sit hidden behind the+ // fullscreen slides, so drop fullscreen to reveal them. (To send notes to+ // a second screen automatically, enable it in the editor's Slide panel+ // before presenting.)+ console.info('[bento-speaker] no 2nd screen — revealing notes in a window')document.exitFullscreen?.().catch(() => {})- showGrantButton()}window.setTimeout(() => { openingSpeaker = false }, 500)}@@ -320,10 +269,6 @@ export function startPresentation(}document.addEventListener('fullscreenchange', onFsChange)if (opts.fullscreen !== false) enterFullscreen()- // Prepare second-screen support: cache the layout if the permission is already- // granted, otherwise show a one-click grant button (the S keypress can't prompt- // for it — its activation is spent on window.open/fullscreen).- void setupSecondScreen()const exit = () => {if (exited) return@@ -536,15 +481,27 @@ function runEnterFx(slide: Slide, section: HTMLElement) {// node would fight it and freeze the dot off its pathif (fx.loop?.type === 'motion-path') returnif (fx.enter) {+ // directional entrances: fade-* nudge 16px, slide-* sweep 120px from an+ // edge. x needs the x transform channel (added to anim.ts).+ const D = 120+ const from = { opacity: 0, x: 0, y: 0 }+ if (fx.enter === 'fade-up') from.y = 16+ else if (fx.enter === 'fade-down') from.y = -16+ else if (fx.enter === 'slide-left') from.x = D // starts to the right, slides in leftward+ else if (fx.enter === 'slide-right') from.x = -D+ else if (fx.enter === 'slide-up') from.y = D+ else if (fx.enter === 'slide-down') from.y = -D+ const slide = fx.enter.startsWith('slide-')anim.fromTo(node,- { opacity: 0, y: fx.enter === 'fade-up' ? 16 : 0 },+ from,{opacity: el.opacity,+ x: 0,y: 0,- duration: 0.55,+ duration: slide ? 0.75 : 0.55,delay: 0.12 + Math.min(step, 24) * 0.05,- ease: 'power2.out',+ ease: slide ? 'power3.out' : 'power2.out',},)}diff --git a/slides/src/screens.ts b/slides/src/screens.tsnew file mode 100644index 00000000..a5515ad4--- /dev/null+++ b/slides/src/screens.ts@@ -0,0 +1,49 @@+// Shared Window Management state.+//+// Granting the browser's "window management" permission needs a DEDICATED user+// gesture — it can't ride the S keypress during present (that activation is+// already spent on window.open / requestFullscreen). So the editor grants it+// from the properties panel BEFORE presenting, we cache the LIVE ScreenDetails+// object here, and present mode reads the second-screen coordinates+// synchronously when the speaker view opens.++let cached: { screens: any[]; currentScreen: any } | null = null++export function windowManagementSupported(): boolean {+ return typeof (window as unknown as { getScreenDetails?: unknown }).getScreenDetails === 'function'+}++export function screensCached(): boolean {+ return !!cached+}++/** Call INSIDE a user gesture. Prompts once if needed, then caches the live+ * details object (it auto-updates as displays change). */+export async function grantScreens(): Promise<{ ok: boolean; screens: number }> {+ const gsd = (window as unknown as { getScreenDetails?: () => Promise<any> }).getScreenDetails+ if (!gsd) return { ok: false, screens: 0 }+ try {+ cached = await gsd.call(window)+ return { ok: true, screens: cached?.screens?.length ?? 1 }+ } catch {+ return { ok: false, screens: 0 }+ }+}++/** At load: if the permission is already granted from a prior session, cache+ * the layout without a prompt so present mode Just Works. */+export async function refreshScreensIfGranted(): Promise<void> {+ if (cached || !windowManagementSupported()) return+ try {+ const state = (await (navigator as unknown as { permissions?: { query?: (o: unknown) => Promise<{ state: string }> } })+ .permissions?.query?.({ name: 'window-management' as PermissionName }))?.state+ if (state === 'granted') await grantScreens()+ } catch { /* query unsupported — the panel button remains the path */ }+}++/** The display to put speaker notes on, or null if there isn't a usable second one. */+export function secondScreen(): any | null {+ const s = cached+ if (!s || !Array.isArray(s.screens) || s.screens.length < 2) return null+ return s.screens.find((x) => x !== s.currentScreen) ?? s.screens.find((x) => !x.isPrimary) ?? s.screens[1]+}