import * as DOM from "../../../../base/browser/dom.js"; import { Disposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { IContextKeyService } from "../../../../platform/contextkey/common/contextkey.service.js"; import { ILayoutService } from "../../../../platform/layout/browser/layoutService.service.js"; import { IMobileVisualViewport } from "./mobileVisualViewport.service.js"; /** * Threshold (in CSS pixels) above which the visual viewport delta is * treated as a virtual keyboard being visible. A few dozen pixels can * appear briefly during URL-bar collapse / address-bar shrink, so we * require a clearly keyboard-sized delta before flipping the context. */ export declare const KEYBOARD_VISIBLE_THRESHOLD_PX = 50; export declare function getMobileViewportDimension(layoutViewport: DOM.Dimension, visualViewport: Pick | null | undefined): DOM.Dimension; /** * Tracks the virtual keyboard height of the agents workbench window via * the `window.visualViewport` API and exposes it to consumers in three * complementary forms: * * 1. As an {@link IObservable} (`keyboardHeight`) for code that wants * to react to keyboard changes via `autorun` / `derived`. * 2. As a CSS custom property (`--vscode-keyboard-height`) set on the * workbench main container, so styles can position fixed UI above * the keyboard without touching JavaScript at all. * 3. As a reactive {@link KeyboardVisibleContext} context key (`true` * when the keyboard height exceeds {@link KEYBOARD_VISIBLE_THRESHOLD_PX}), * so `when:` clauses on commands/menus can adapt to the keyboard. * * # Why this helper exists * * On iOS Safari (and to a lesser extent some Android browsers), the * *layout viewport* — what `vh` units, `window.innerHeight`, and * `position: fixed` resolve against — does NOT shrink when the virtual * keyboard opens. Only the *visual viewport* (the actually visible * area) shrinks. As a consequence, naive layouts that anchor to the * bottom of the layout viewport end up hidden behind the keyboard. * * The standard `window.visualViewport` API exposes the real visible * area and fires `resize` / `scroll` events when the keyboard opens * or closes. This helper subscribes to those events once for the * lifetime of the workbench window and publishes the keyboard height * (`max(0, window.innerHeight - visualViewport.height)`). * * # Auxiliary windows * * The helper uses {@link DOM.getWindow} to resolve the correct window * object for the layout-service main container, so it works correctly * when the workbench is hosted inside an auxiliary window (each aux * window has its own `visualViewport`). * * # Graceful degradation * * Browsers that do not implement `visualViewport` (very old engines, * some embedded webviews) get a constant `keyboardHeight` of `0`, no * CSS variable update, and a context key that stays `false`. Consumers * never need to check for the API themselves. */ export declare class MobileVisualViewport extends Disposable implements IMobileVisualViewport { readonly _serviceBrand: undefined; private readonly _keyboardHeight; readonly keyboardHeight: IObservable; readonly isKeyboardVisible: IObservable; private readonly _keyboardVisibleCtx; private readonly mainContainer; constructor(contextKeyService: IContextKeyService, layoutService: ILayoutService); dispose(): void; }