gesso-framework 0.6.10 → 0.6.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # gesso-framework
2
2
 
3
+ ## 0.6.11
4
+
5
+ ### Patch Changes
6
+
7
+ - `ShellService.windowActive` says whether the window is the one the person is using: shown, and holding the keyboard focus. It is false while the window is behind another, minimised or in a background tab, and the shell reports it once at start-up and on every focus, blur and visibility change, on the main thread and over the render worker protocol (a new `windowActive` message). It is for work that should happen when the person comes back rather than on a clock, such as reading again what may have changed while they were away: `ctx.effect(shell.windowActive.pipe(filter(Boolean)), () => channel.send.refresh())`. A document that cannot say where the focus is is taken to have it.
8
+ - Updated dependencies
9
+ - gesso-core@0.6.11
10
+
3
11
  ## 0.6.10
4
12
 
5
13
  ### Patch Changes
@@ -1840,6 +1840,7 @@ declare class ShellService {
1840
1840
  private handler;
1841
1841
  private readonly scheme;
1842
1842
  private readonly contrastState;
1843
+ private readonly activeState;
1843
1844
  private readonly insets;
1844
1845
  private readonly isFullscreen;
1845
1846
  /** Popups asked for and not yet answered, by the id sent with each. */
@@ -1895,6 +1896,17 @@ declare class ShellService {
1895
1896
  * );
1896
1897
  */
1897
1898
  readonly contrast: ReadableCell<UiContrast>;
1899
+ /**
1900
+ * Whether the window is the one the person is using: shown, and holding
1901
+ * the keyboard focus. False while it is behind another window,
1902
+ * minimised, or in a background tab. True until a shell says otherwise.
1903
+ *
1904
+ * For work that should happen when the person comes back rather than
1905
+ * on a clock: reading again what may have changed while they were away.
1906
+ *
1907
+ * ctx.effect(shell.windowActive.pipe(filter(Boolean)), () => channel.send.refresh());
1908
+ */
1909
+ readonly windowActive: ReadableCell<boolean>;
1898
1910
  /** The current appearance, for code that needs it without subscribing. */
1899
1911
  get currentColorScheme(): ColorScheme;
1900
1912
  /**
@@ -1926,6 +1938,8 @@ declare class ShellService {
1926
1938
  * answer, and `colorScheme` is how an application hears about it.
1927
1939
  */
1928
1940
  applyColorScheme(scheme: ColorScheme): void;
1941
+ /** Called by the runtime when the shell reports whether the window is active; not for applications. */
1942
+ applyWindowActive(active: boolean): void;
1929
1943
  /** Called by the runtime when the shell reports the contrast; not for applications. */
1930
1944
  applyContrast(contrast: UiContrast): void;
1931
1945
  /**
@@ -3755,6 +3769,8 @@ declare class GessoRuntime {
3755
3769
  * dark should look like.
3756
3770
  */
3757
3771
  setColorScheme(scheme: ColorScheme): void;
3772
+ /** Whether the window is the one in use, passed straight to `ShellService`; see `ShellService.windowActive`. */
3773
+ setWindowActive(active: boolean): void;
3758
3774
  /** The contrast the platform asks for, passed straight to `ShellService`; see `ShellService.contrast`. */
3759
3775
  setContrast(contrast: UiContrast): void;
3760
3776
  /**
@@ -4673,6 +4689,11 @@ type ShellToRuntimeMessage = {
4673
4689
  type: 'contrast';
4674
4690
  contrast: UiContrast;
4675
4691
  } |
4692
+ /** Whether the window is shown and holds the focus; once at start-up and on every change. See `ShellService.windowActive`. */
4693
+ {
4694
+ type: 'windowActive';
4695
+ active: boolean;
4696
+ } |
4676
4697
  /**
4677
4698
  * What the window's own chrome is covering on each edge: the safe
4678
4699
  * area a notch or a home indicator takes, and the strip a soft
@@ -6372,6 +6393,7 @@ declare class GessoApp {
6372
6393
  private fullscreen;
6373
6394
  private detachReducedMotion;
6374
6395
  private detachContrast;
6396
+ private detachWindowActive;
6375
6397
  /** Stops watching `prefers-color-scheme`; null while overridden. */
6376
6398
  private detachColorScheme;
6377
6399
  /** Stops watching `visualViewport` for the safe area and the keyboard. */
@@ -8453,4 +8475,4 @@ declare class RenderWorkerApp {
8453
8475
  }
8454
8476
  //#endregion
8455
8477
  export { StorageAdapter as $, UiOwnerReport as $n, Resource as $r, FontFaceDeclaration as $t, Presence as A, AudioState as An, Channel as Ar, ActionCause as At, PersistedOptions as B, ShellFileType as Bn, bind as Br, UiTreeSnapshot as Bt, FocusService as C, formatUrl as Cn, pickKeys as Cr, AppLogicEndpoint as Ct, FindService as D, AudioRequest as Dn, findUnplainPath as Dr, ShellHistoryMode as Dt, TextService as E, AudioMetadata as En, createChannelRegistry as Er, ShellHistory as Et, AudioSinkOptions as F, UiDuration as Fn, ControlledOptions as Fr, DevtoolsEvent as Ft, IndexedDbStorage as G, ShellStorageResult as Gn, EachKey as Gr, FrameMetrics as Gt, persisted as H, ShellRequest as Hn, ShowProps as Hr, RuntimeErrorSource as Ht, AudioSinkOutput as I, UiEasingChoice as In, ControlledValue as Ir, DevtoolsRequest as It, OpfsFileHandle as J, observeColorScheme as Jn, debounced as Jr, GessoRuntimeOptions as Jt, IndexedDbStorageOptions as K, ColorScheme as Kn, EachProps as Kr, FramePhaseTimings as Kt, MediaSessionLike as L, ShellFile as Ln, controlled as Lr, FrameEntry as Lt, RouterOutlet as M, AnimateOptions as Mn, Inject as Mr, ChannelErrorEntry as Mt, AudioElementLike as N, AnimationService as Nn, Input as Nr, CommandEntry as Nt, observeMediaQuery as O, AudioSample as On, requirePlainData as Or, ShellHistoryOptions as Ot, AudioSink as P, SpringOptions as Pn, Output as Pr, ConsoleEntry as Pt, MemoryStorage as Q, UiNodeReport as Qn, mutate as Qr, UiFramePhase as Qt, audioClock as R, ShellFileRequest as Rn, ThemeTokenCell as Rr, PatchEntry as Rt, writeClipboard as S, buildPath as Sn, pick as Sr, createApp as St, EditingService as T, AudioAction as Tn, ChannelRegistryHandle as Tr, WorkerAppOptions as Tt, ShellStorage as U, ShellService as Un, show as Ur, RuntimeToShellMessage as Ut, PersistedState as V, ShellRecentFile as Vn, Show as Vr, treeText as Vt, ShellStorageOptions as W, ShellStorageOp as Wn, Each as Wr, ShellToRuntimeMessage as Wt, OpfsStorageOptions as X, NodePathTarget as Xn, MutateOptions as Xr, RuntimeInput as Xt, OpfsStorage as Y, BoundStream as Yn, throttled as Yr, RendererChoice as Yt, OpfsWritable as Z, UiEnvironmentReport as Zn, Mutation as Zr, UI_FRAME_PHASES as Zt, EditingMirrorTarget as _, derive as _i, RouteOptions as _n, createComponent as _r, GessoAppOptions as _t, UiRole as a, select as ai, MediaOptions as an, formatAge as ar, storageReadValue as at, EditingProxy as b, to as bn, isComponentElement as br, WebMcpChoice as bt, UiSemanticsPatch as c, FanOut as ci, RouteMatch as cn, formatStream as cr, UndoableOptions as ct, markNow as d, ComputedCell as di, RouterService as dn, ComponentHost as dr, UndoStackOptions as dt, ResourceOptions as ei, FontFaceLike as en, UiPropOrigin as er, StorageOutcome as et, measureSpan as f, ComputedOptions as fi, RouteState as fn, OverlayLayer as fr, UndoTransaction as ft, renderRoot as g, Equality as gi, RouteGuard as gn, OverlayService as gr, GessoApp as gt, RenderWorkerApp as h, DeriveOptions as hi, RouteDefinition as hn, OverlayRect as hr, shellStorageDenied as ht, UI_SEMANTIC_STATES as i, SelectOptions as ii, FontService as in, describeStream as ir, storageReadFailure as it, PresenceProps as j, AudioStatus as jn, Define as jr, ActionEntry as jt, observeReducedMotion as k, AudioService as kn, ChannelRegistry as kr, createShellHistory as kt, UiSemanticsRecord$1 as l, FanOutOptions as li, RouterHistorySink as ln, printPropValue as lr, undoable as lt, setPerformanceMarks$1 as m, computed as mi, RouteContext as mn, OverlayPlacement as mr, performShellStorage as mt, MARK_PREFIX as n, ResourceStatus as ni, FontFamilyStatus as nn, UiSemanticsReport as nr, classifyStorageError as nt, UiSemanticState as o, FanCell as oi, MediaService as on, formatNodePath as or, UndoShortcutOptions as ot, performanceMarksEnabled as p, ReadSource as pi, OutletProps as pn, OverlayEntry as pr, ShellLocalStore as pt, OpfsDirectory as q, ColorSchemePreference as qn, each as qr, GessoRuntime as qt, UI_ROLES as r, resource as ri, FontHost as rn, UiStreamReport as rr, storageErrorMessage as rt, UiSemanticsMap$1 as s, FanKey as si, RouteAnswer as sn, formatNodeReport as sr, registerUndoShortcuts as st, EditingState$1 as t, ResourceState as ti, FontFamilyDeclaration as tn, UiPropReport as tr, StorageRead as tt, markInstant as u, fanOut as ui, RouterRoutes as un, ComponentHostResolver as ur, UndoStack as ut, SemanticsMirror as v, ServiceRegistry as vi, RouteTarget as vn, ComponentElement as vr, createSyncApp as vt, ScrollService as w, parseUrl as wn, ChannelRegistration as wr, WorkerApp as wt, EditingProxySink as x, RouteParams as xn, structurallyEqual as xr, CreateAppOptions as xt, SemanticsMirrorSink as y, route as yn, FrameworkChild as yr, GessoAppBuilder as yt, FrameService as z, ShellFileResult as zn, themeTokenCell as zr, UiTreeNode as zt };
8456
- //# sourceMappingURL=index-oHQAJMqR.d.ts.map
8478
+ //# sourceMappingURL=index-CnftxR8z.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { _ as channel, a as isChannelHostMessage, c as applyPatch, d as ChannelSpec, f as ChannelToken, g as ViewOf, h as CommandsOf, i as isChannelClientMessage, l as applyPatches, m as CommandMap, n as ChannelHostMessage, o as Patch, p as Command, r as ChannelPort, s as PatchPath, t as ChannelClientMessage, u as diffProjection, v as defineChannel, y as viewKeys } from "./ChannelProtocol-ByNoHujM.js";
2
2
  import { A as portHandle, C as MessageEndpoint, D as isHubMessage, E as WorkerHandle, F as JsonSchema, I as channelSchema, L as describeChannel, M as workerHandle, N as ChannelSchema, O as isPortErrorMessage, P as CommandSchema, S as APPLICATION_WORKER, T as PortHost, _ as serve, b as ProvidedChannel, g as ServedChannel, j as servePorts, k as isPortHandshake, v as serveChannels, w as PortHandshake, x as provide, y as ChannelSource } from "./ui-e4RHm8Mt.js";
3
3
  import { C as internalState, S as InternalState, _ as ReadableCell, a as ComponentType, b as isOutputTarget, c as isClassComponent, d as bounds, f as EmitArgs, g as OutputTarget, h as OutputCell, i as ComponentProps, l as ChannelReplica, m as InputCell, o as FunctionComponent, p as EmitValue, r as ComponentContext, s as Inputs, t as ClassComponent, u as BoundsCell, v as input, w as Component, x as output, y as into } from "./FunctionComponent-fYMdePtH.js";
4
- import { $ as StorageAdapter, $n as UiOwnerReport, $r as Resource, $t as FontFaceDeclaration, A as Presence, An as AudioState, Ar as Channel, At as ActionCause, B as PersistedOptions, Bn as ShellFileType, Br as bind, Bt as UiTreeSnapshot, C as FocusService, Cn as formatUrl, Cr as pickKeys, Ct as AppLogicEndpoint, D as FindService, Dn as AudioRequest, Dr as findUnplainPath, Dt as ShellHistoryMode, E as TextService, En as AudioMetadata, Er as createChannelRegistry, Et as ShellHistory, F as AudioSinkOptions, Fn as UiDuration, Fr as ControlledOptions, Ft as DevtoolsEvent, G as IndexedDbStorage, Gn as ShellStorageResult, Gr as EachKey, Gt as FrameMetrics, H as persisted, Hn as ShellRequest, Hr as ShowProps, Ht as RuntimeErrorSource, I as AudioSinkOutput, In as UiEasingChoice, Ir as ControlledValue, It as DevtoolsRequest, J as OpfsFileHandle, Jn as observeColorScheme, Jr as debounced, Jt as GessoRuntimeOptions, K as IndexedDbStorageOptions, Kn as ColorScheme, Kr as EachProps, Kt as FramePhaseTimings, L as MediaSessionLike, Ln as ShellFile, Lr as controlled, Lt as FrameEntry, M as RouterOutlet, Mn as AnimateOptions, Mr as Inject, Mt as ChannelErrorEntry, N as AudioElementLike, Nn as AnimationService, Nr as Input, Nt as CommandEntry, O as observeMediaQuery, On as AudioSample, Or as requirePlainData, Ot as ShellHistoryOptions, P as AudioSink, Pn as SpringOptions, Pr as Output, Pt as ConsoleEntry, Q as MemoryStorage, Qn as UiNodeReport, Qr as mutate, Qt as UiFramePhase, R as audioClock, Rn as ShellFileRequest, Rr as ThemeTokenCell, Rt as PatchEntry, S as writeClipboard, Sn as buildPath, Sr as pick, St as createApp, T as EditingService, Tn as AudioAction, Tr as ChannelRegistryHandle, Tt as WorkerAppOptions, U as ShellStorage, Un as ShellService, Ur as show, Ut as RuntimeToShellMessage, V as PersistedState, Vn as ShellRecentFile, Vr as Show, Vt as treeText, W as ShellStorageOptions, Wn as ShellStorageOp, Wr as Each, Wt as ShellToRuntimeMessage, X as OpfsStorageOptions, Xn as NodePathTarget, Xr as MutateOptions, Xt as RuntimeInput, Y as OpfsStorage, Yn as BoundStream, Yr as throttled, Yt as RendererChoice, Z as OpfsWritable, Zn as UiEnvironmentReport, Zr as Mutation, Zt as UI_FRAME_PHASES, _ as EditingMirrorTarget, _i as derive, _n as RouteOptions, _r as createComponent, _t as GessoAppOptions, a as UiRole, ai as select, an as MediaOptions, ar as formatAge, at as storageReadValue, b as EditingProxy, bn as to, br as isComponentElement, bt as WebMcpChoice, c as UiSemanticsPatch, ci as FanOut, cn as RouteMatch, cr as formatStream, ct as UndoableOptions, d as markNow, di as ComputedCell, dn as RouterService, dr as ComponentHost, dt as UndoStackOptions, ei as ResourceOptions, en as FontFaceLike, er as UiPropOrigin, et as StorageOutcome, f as measureSpan, fi as ComputedOptions, fn as RouteState, fr as OverlayLayer, ft as UndoTransaction, g as renderRoot, gi as Equality, gn as RouteGuard, gr as OverlayService, gt as GessoApp, h as RenderWorkerApp, hi as DeriveOptions, hn as RouteDefinition, hr as OverlayRect, ht as shellStorageDenied, i as UI_SEMANTIC_STATES, ii as SelectOptions, in as FontService, ir as describeStream, it as storageReadFailure, j as PresenceProps, jn as AudioStatus, jr as Define, jt as ActionEntry, k as observeReducedMotion, kn as AudioService, kr as ChannelRegistry, kt as createShellHistory, l as UiSemanticsRecord, li as FanOutOptions, ln as RouterHistorySink, lr as printPropValue, lt as undoable, m as setPerformanceMarks, mi as computed, mn as RouteContext, mr as OverlayPlacement, mt as performShellStorage, n as MARK_PREFIX, ni as ResourceStatus, nn as FontFamilyStatus, nr as UiSemanticsReport, nt as classifyStorageError, o as UiSemanticState, oi as FanCell, on as MediaService, or as formatNodePath, ot as UndoShortcutOptions, p as performanceMarksEnabled, pi as ReadSource, pn as OutletProps, pr as OverlayEntry, pt as ShellLocalStore, q as OpfsDirectory, qn as ColorSchemePreference, qr as each, qt as GessoRuntime, r as UI_ROLES, ri as resource, rn as FontHost, rr as UiStreamReport, rt as storageErrorMessage, s as UiSemanticsMap, si as FanKey, sn as RouteAnswer, sr as formatNodeReport, st as registerUndoShortcuts, t as EditingState, ti as ResourceState, tn as FontFamilyDeclaration, tr as UiPropReport, tt as StorageRead, u as markInstant, ui as fanOut, un as RouterRoutes, ur as ComponentHostResolver, ut as UndoStack, v as SemanticsMirror, vi as ServiceRegistry, vn as RouteTarget, vr as ComponentElement, vt as createSyncApp, w as ScrollService, wn as parseUrl, wr as ChannelRegistration, wt as WorkerApp, x as EditingProxySink, xn as RouteParams, xr as structurallyEqual, xt as CreateAppOptions, y as SemanticsMirrorSink, yn as route, yr as FrameworkChild, yt as GessoAppBuilder, z as FrameService, zn as ShellFileResult, zr as themeTokenCell, zt as UiTreeNode } from "./index-oHQAJMqR.js";
4
+ import { $ as StorageAdapter, $n as UiOwnerReport, $r as Resource, $t as FontFaceDeclaration, A as Presence, An as AudioState, Ar as Channel, At as ActionCause, B as PersistedOptions, Bn as ShellFileType, Br as bind, Bt as UiTreeSnapshot, C as FocusService, Cn as formatUrl, Cr as pickKeys, Ct as AppLogicEndpoint, D as FindService, Dn as AudioRequest, Dr as findUnplainPath, Dt as ShellHistoryMode, E as TextService, En as AudioMetadata, Er as createChannelRegistry, Et as ShellHistory, F as AudioSinkOptions, Fn as UiDuration, Fr as ControlledOptions, Ft as DevtoolsEvent, G as IndexedDbStorage, Gn as ShellStorageResult, Gr as EachKey, Gt as FrameMetrics, H as persisted, Hn as ShellRequest, Hr as ShowProps, Ht as RuntimeErrorSource, I as AudioSinkOutput, In as UiEasingChoice, Ir as ControlledValue, It as DevtoolsRequest, J as OpfsFileHandle, Jn as observeColorScheme, Jr as debounced, Jt as GessoRuntimeOptions, K as IndexedDbStorageOptions, Kn as ColorScheme, Kr as EachProps, Kt as FramePhaseTimings, L as MediaSessionLike, Ln as ShellFile, Lr as controlled, Lt as FrameEntry, M as RouterOutlet, Mn as AnimateOptions, Mr as Inject, Mt as ChannelErrorEntry, N as AudioElementLike, Nn as AnimationService, Nr as Input, Nt as CommandEntry, O as observeMediaQuery, On as AudioSample, Or as requirePlainData, Ot as ShellHistoryOptions, P as AudioSink, Pn as SpringOptions, Pr as Output, Pt as ConsoleEntry, Q as MemoryStorage, Qn as UiNodeReport, Qr as mutate, Qt as UiFramePhase, R as audioClock, Rn as ShellFileRequest, Rr as ThemeTokenCell, Rt as PatchEntry, S as writeClipboard, Sn as buildPath, Sr as pick, St as createApp, T as EditingService, Tn as AudioAction, Tr as ChannelRegistryHandle, Tt as WorkerAppOptions, U as ShellStorage, Un as ShellService, Ur as show, Ut as RuntimeToShellMessage, V as PersistedState, Vn as ShellRecentFile, Vr as Show, Vt as treeText, W as ShellStorageOptions, Wn as ShellStorageOp, Wr as Each, Wt as ShellToRuntimeMessage, X as OpfsStorageOptions, Xn as NodePathTarget, Xr as MutateOptions, Xt as RuntimeInput, Y as OpfsStorage, Yn as BoundStream, Yr as throttled, Yt as RendererChoice, Z as OpfsWritable, Zn as UiEnvironmentReport, Zr as Mutation, Zt as UI_FRAME_PHASES, _ as EditingMirrorTarget, _i as derive, _n as RouteOptions, _r as createComponent, _t as GessoAppOptions, a as UiRole, ai as select, an as MediaOptions, ar as formatAge, at as storageReadValue, b as EditingProxy, bn as to, br as isComponentElement, bt as WebMcpChoice, c as UiSemanticsPatch, ci as FanOut, cn as RouteMatch, cr as formatStream, ct as UndoableOptions, d as markNow, di as ComputedCell, dn as RouterService, dr as ComponentHost, dt as UndoStackOptions, ei as ResourceOptions, en as FontFaceLike, er as UiPropOrigin, et as StorageOutcome, f as measureSpan, fi as ComputedOptions, fn as RouteState, fr as OverlayLayer, ft as UndoTransaction, g as renderRoot, gi as Equality, gn as RouteGuard, gr as OverlayService, gt as GessoApp, h as RenderWorkerApp, hi as DeriveOptions, hn as RouteDefinition, hr as OverlayRect, ht as shellStorageDenied, i as UI_SEMANTIC_STATES, ii as SelectOptions, in as FontService, ir as describeStream, it as storageReadFailure, j as PresenceProps, jn as AudioStatus, jr as Define, jt as ActionEntry, k as observeReducedMotion, kn as AudioService, kr as ChannelRegistry, kt as createShellHistory, l as UiSemanticsRecord, li as FanOutOptions, ln as RouterHistorySink, lr as printPropValue, lt as undoable, m as setPerformanceMarks, mi as computed, mn as RouteContext, mr as OverlayPlacement, mt as performShellStorage, n as MARK_PREFIX, ni as ResourceStatus, nn as FontFamilyStatus, nr as UiSemanticsReport, nt as classifyStorageError, o as UiSemanticState, oi as FanCell, on as MediaService, or as formatNodePath, ot as UndoShortcutOptions, p as performanceMarksEnabled, pi as ReadSource, pn as OutletProps, pr as OverlayEntry, pt as ShellLocalStore, q as OpfsDirectory, qn as ColorSchemePreference, qr as each, qt as GessoRuntime, r as UI_ROLES, ri as resource, rn as FontHost, rr as UiStreamReport, rt as storageErrorMessage, s as UiSemanticsMap, si as FanKey, sn as RouteAnswer, sr as formatNodeReport, st as registerUndoShortcuts, t as EditingState, ti as ResourceState, tn as FontFamilyDeclaration, tr as UiPropReport, tt as StorageRead, u as markInstant, ui as fanOut, un as RouterRoutes, ur as ComponentHostResolver, ut as UndoStack, v as SemanticsMirror, vi as ServiceRegistry, vn as RouteTarget, vr as ComponentElement, vt as createSyncApp, w as ScrollService, wn as parseUrl, wr as ChannelRegistration, wt as WorkerApp, x as EditingProxySink, xn as RouteParams, xr as structurallyEqual, xt as CreateAppOptions, y as SemanticsMirrorSink, yn as route, yr as FrameworkChild, yt as GessoAppBuilder, z as FrameService, zn as ShellFileResult, zr as themeTokenCell, zt as UiTreeNode } from "./index-CnftxR8z.js";
5
5
  export { APPLICATION_WORKER, type ActionCause, type ActionEntry, type AnimateOptions, AnimationService, type AppLogicEndpoint, type AudioAction, type AudioElementLike, type AudioMetadata, type AudioRequest, type AudioSample, AudioService, AudioSink, type AudioSinkOptions, type AudioSinkOutput, type AudioState, type AudioStatus, type BoundStream, BoundsCell, Channel, type ChannelClientMessage, type ChannelErrorEntry, type ChannelHostMessage, type ChannelPort, type ChannelRegistration, ChannelRegistry, type ChannelRegistryHandle, ChannelReplica, type ChannelSchema, type ChannelSource, type ChannelSpec, type ChannelToken, type ClassComponent, type ColorScheme, type ColorSchemePreference, type Command, type CommandEntry, type CommandMap, type CommandSchema, type CommandsOf, Component, type ComponentContext, type ComponentElement, ComponentHost, ComponentHostResolver, type ComponentProps, type ComponentType, ComputedCell, type ComputedOptions, type ConsoleEntry, type ControlledOptions, type ControlledValue, type CreateAppOptions, Define, type DeriveOptions, type DevtoolsEvent, type DevtoolsRequest, Each, type EachKey, type EachProps, type EditingMirrorTarget, EditingProxy, type EditingProxySink, EditingService, type EditingState, type EmitArgs, type EmitValue, type Equality, FanCell, type FanKey, FanOut, type FanOutOptions, FindService, FocusService, type FontFaceDeclaration, type FontFaceLike, type FontFamilyDeclaration, type FontFamilyStatus, type FontHost, FontService, type FrameEntry, type FrameMetrics, type FramePhaseTimings, FrameService, type FrameworkChild, type FunctionComponent, GessoApp, GessoAppBuilder, type GessoAppOptions, GessoRuntime, type GessoRuntimeOptions, IndexedDbStorage, type IndexedDbStorageOptions, Inject, Input, InputCell, type Inputs, InternalState, type JsonSchema, MARK_PREFIX, type MediaOptions, MediaService, type MediaSessionLike, MemoryStorage, type MessageEndpoint, type MutateOptions, type Mutation, type NodePathTarget, type OpfsDirectory, type OpfsFileHandle, OpfsStorage, type OpfsStorageOptions, type OpfsWritable, type OutletProps, Output, type OutputCell, type OutputTarget, type OverlayEntry, OverlayLayer, type OverlayPlacement, type OverlayRect, OverlayService, type Patch, type PatchEntry, type PatchPath, type PersistedOptions, PersistedState, type PortHandshake, type PortHost, Presence, type PresenceProps, ProvidedChannel, type ReadSource, type ReadableCell, RenderWorkerApp, type RendererChoice, Resource, type ResourceOptions, type ResourceState, type ResourceStatus, type RouteAnswer, type RouteContext, type RouteDefinition, type RouteGuard, type RouteMatch, type RouteOptions, type RouteParams, RouteState, type RouteTarget, type RouterHistorySink, RouterOutlet, type RouterRoutes, RouterService, type RuntimeErrorSource, type RuntimeInput, type RuntimeToShellMessage, ScrollService, type SelectOptions, SemanticsMirror, type SemanticsMirrorSink, type ServedChannel, ServiceRegistry, type ShellFile, type ShellFileRequest, type ShellFileResult, type ShellFileType, type ShellHistory, type ShellHistoryMode, type ShellHistoryOptions, type ShellLocalStore, type ShellRecentFile, type ShellRequest, ShellService, ShellStorage, type ShellStorageOp, type ShellStorageOptions, type ShellStorageResult, type ShellToRuntimeMessage, Show, type ShowProps, type SpringOptions, type StorageAdapter, type StorageOutcome, type StorageRead, TextService, ThemeTokenCell, UI_FRAME_PHASES, UI_ROLES, UI_SEMANTIC_STATES, type UiDuration, type UiEasingChoice, type UiEnvironmentReport, type UiFramePhase, type UiNodeReport, type UiOwnerReport, type UiPropOrigin, type UiPropReport, type UiRole, type UiSemanticState, type UiSemanticsMap, type UiSemanticsPatch, type UiSemanticsRecord, type UiSemanticsReport, type UiStreamReport, type UiTreeNode, type UiTreeSnapshot, type UndoShortcutOptions, UndoStack, type UndoStackOptions, type UndoTransaction, type UndoableOptions, type ViewOf, type WebMcpChoice, WorkerApp, type WorkerAppOptions, type WorkerHandle, applyPatch, applyPatches, audioClock, bind, bounds, buildPath, channel, channelSchema, classifyStorageError, computed, controlled, createApp, createChannelRegistry, createComponent, createShellHistory, createSyncApp, debounced, defineChannel, derive, describeChannel, describeStream, diffProjection, each, fanOut, findUnplainPath, formatAge, formatNodePath, formatNodeReport, formatStream, formatUrl, input, internalState, into, isChannelClientMessage, isChannelHostMessage, isClassComponent, isComponentElement, isHubMessage, isOutputTarget, isPortErrorMessage, isPortHandshake, markInstant, markNow, measureSpan, mutate, observeColorScheme, observeMediaQuery, observeReducedMotion, output, parseUrl, performShellStorage, performanceMarksEnabled, persisted, pick, pickKeys, portHandle, printPropValue, provide, registerUndoShortcuts, renderRoot, requirePlainData, resource, route, select, serve, serveChannels, servePorts, setPerformanceMarks, shellStorageDenied, show, storageErrorMessage, storageReadFailure, storageReadValue, structurallyEqual, themeTokenCell, throttled, to, treeText, undoable, viewKeys, workerHandle, writeClipboard };
package/dist/index.js CHANGED
@@ -1795,6 +1795,7 @@ var ShellService = class {
1795
1795
  handler = null;
1796
1796
  scheme = internalState("light");
1797
1797
  contrastState = internalState("standard");
1798
+ activeState = internalState(true);
1798
1799
  insets = internalState(noInsets);
1799
1800
  isFullscreen = internalState(false);
1800
1801
  /** Popups asked for and not yet answered, by the id sent with each. */
@@ -1850,6 +1851,17 @@ var ShellService = class {
1850
1851
  * );
1851
1852
  */
1852
1853
  contrast = this.contrastState;
1854
+ /**
1855
+ * Whether the window is the one the person is using: shown, and holding
1856
+ * the keyboard focus. False while it is behind another window,
1857
+ * minimised, or in a background tab. True until a shell says otherwise.
1858
+ *
1859
+ * For work that should happen when the person comes back rather than
1860
+ * on a clock: reading again what may have changed while they were away.
1861
+ *
1862
+ * ctx.effect(shell.windowActive.pipe(filter(Boolean)), () => channel.send.refresh());
1863
+ */
1864
+ windowActive = this.activeState;
1853
1865
  /** The current appearance, for code that needs it without subscribing. */
1854
1866
  get currentColorScheme() {
1855
1867
  return this.scheme.value;
@@ -1889,6 +1901,10 @@ var ShellService = class {
1889
1901
  applyColorScheme(scheme) {
1890
1902
  if (this.scheme.value !== scheme) this.scheme.value = scheme;
1891
1903
  }
1904
+ /** Called by the runtime when the shell reports whether the window is active; not for applications. */
1905
+ applyWindowActive(active) {
1906
+ if (this.activeState.value !== active) this.activeState.value = active;
1907
+ }
1892
1908
  /** Called by the runtime when the shell reports the contrast; not for applications. */
1893
1909
  applyContrast(contrast) {
1894
1910
  if (this.contrastState.value !== contrast) this.contrastState.value = contrast;
@@ -3767,6 +3783,37 @@ function observeContrast(onChange) {
3767
3783
  };
3768
3784
  }
3769
3785
  //#endregion
3786
+ //#region src/app/windowActive.ts
3787
+ /**
3788
+ * Watches whether the window is the one the person is using: shown, and
3789
+ * holding the keyboard focus. A window behind another, minimised, or in
3790
+ * a background tab is not.
3791
+ *
3792
+ * Shell-side, reported once at once and again on change, for the reason
3793
+ * `observeColorScheme` gives: a window that starts in the background
3794
+ * fires nothing until it is brought forward.
3795
+ */
3796
+ function observeWindowActive(onChange) {
3797
+ let last = null;
3798
+ const report = () => {
3799
+ const focused = typeof document.hasFocus === "function" ? document.hasFocus() : true;
3800
+ const active = document.visibilityState === "visible" && focused;
3801
+ if (active !== last) {
3802
+ last = active;
3803
+ onChange(active);
3804
+ }
3805
+ };
3806
+ window.addEventListener("focus", report);
3807
+ window.addEventListener("blur", report);
3808
+ document.addEventListener("visibilitychange", report);
3809
+ report();
3810
+ return () => {
3811
+ window.removeEventListener("focus", report);
3812
+ window.removeEventListener("blur", report);
3813
+ document.removeEventListener("visibilitychange", report);
3814
+ };
3815
+ }
3816
+ //#endregion
3770
3817
  //#region src/app/reducedMotion.ts
3771
3818
  /**
3772
3819
  * Watches the platform's reduced-motion preference.
@@ -5023,6 +5070,10 @@ var WorkerApp = class {
5023
5070
  type: "contrast",
5024
5071
  contrast
5025
5072
  }));
5073
+ const detachWindowActive = observeWindowActive((active) => this.post({
5074
+ type: "windowActive",
5075
+ active
5076
+ }));
5026
5077
  const onPointerMove = (event) => {
5027
5078
  const { x, y } = toLocal(event.clientX, event.clientY);
5028
5079
  const move = {
@@ -5130,6 +5181,7 @@ var WorkerApp = class {
5130
5181
  return () => {
5131
5182
  detachReducedMotion();
5132
5183
  detachContrast();
5184
+ detachWindowActive();
5133
5185
  detachFullscreen();
5134
5186
  detachFileDrop();
5135
5187
  canvas.removeEventListener("mousedown", onMouseDown);
@@ -7956,6 +8008,10 @@ var GessoRuntime = class {
7956
8008
  setColorScheme(scheme) {
7957
8009
  this.services.get(ShellService).applyColorScheme(scheme);
7958
8010
  }
8011
+ /** Whether the window is the one in use, passed straight to `ShellService`; see `ShellService.windowActive`. */
8012
+ setWindowActive(active) {
8013
+ this.services.get(ShellService).applyWindowActive(active);
8014
+ }
7959
8015
  /** The contrast the platform asks for, passed straight to `ShellService`; see `ShellService.contrast`. */
7960
8016
  setContrast(contrast) {
7961
8017
  this.services.get(ShellService).applyContrast(contrast);
@@ -9853,6 +9909,7 @@ var GessoApp = class {
9853
9909
  fullscreen = false;
9854
9910
  detachReducedMotion = null;
9855
9911
  detachContrast = null;
9912
+ detachWindowActive = null;
9856
9913
  /** Stops watching `prefers-color-scheme`; null while overridden. */
9857
9914
  detachColorScheme = null;
9858
9915
  /** Stops watching `visualViewport` for the safe area and the keyboard. */
@@ -10065,6 +10122,8 @@ var GessoApp = class {
10065
10122
  this.detachReducedMotion = null;
10066
10123
  this.detachContrast?.();
10067
10124
  this.detachContrast = null;
10125
+ this.detachWindowActive?.();
10126
+ this.detachWindowActive = null;
10068
10127
  this.detachColorScheme?.();
10069
10128
  this.detachColorScheme = null;
10070
10129
  this.detachViewportInsets?.();
@@ -10124,6 +10183,7 @@ var GessoApp = class {
10124
10183
  }
10125
10184
  this.detachReducedMotion = observeReducedMotion((reduced) => this.runtime.setReducedMotion(reduced));
10126
10185
  this.detachContrast = observeContrast((contrast) => this.runtime.setContrast(contrast));
10186
+ this.detachWindowActive = observeWindowActive((active) => this.runtime.setWindowActive(active));
10127
10187
  this.setColorScheme(this.colorSchemePreference);
10128
10188
  }
10129
10189
  /**
@@ -11382,6 +11442,9 @@ var RenderWorkerApp = class {
11382
11442
  case "contrast":
11383
11443
  runtime.setContrast(message.contrast);
11384
11444
  break;
11445
+ case "windowActive":
11446
+ runtime.setWindowActive(message.active);
11447
+ break;
11385
11448
  case "viewportInsets":
11386
11449
  runtime.setViewportInsets(message.insets);
11387
11450
  break;