gesso-framework 0.6.1 → 0.6.3

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,20 @@
1
1
  # gesso-framework
2
2
 
3
+ ## 0.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - An app whose WebGPU device is lost gets a new one and carries on. The fallback it used to take, Canvas2D on the same canvas, could never work: that canvas already holds a WebGPU context, so `getContext('2d')` answers null and the fallback threw on every frame. The runtime now asks the renderer to recover on a new device, and the loss itself requests the frame that starts it. Each renderer listens to its own device's loss rather than to every device on the page. `WebGPURenderer` gains `recover()` and an `onLost` option.
8
+ - Updated dependencies
9
+ - gesso-core@0.6.3
10
+
11
+ ## 0.6.2
12
+
13
+ ### Patch Changes
14
+
15
+ - 0304a05: A canvas the browser empties and hands back is repainted. Chrome reclaims the canvas of a tab left hidden long enough, and a GPU process restart (a Mac waking from sleep) empties every canvas; nothing in the tree had changed, so no frame came and the app sat as a blank rectangle. The runtime now repaints the whole tree on `contextrestored`, and on the way back from hidden for engines that do not fire it. `UiRenderer` gains an optional `surfaceRestored()`, which `Canvas2DRenderer` implements by dropping its scroll layers.
16
+ - gesso-core@0.6.2
17
+
3
18
  ## 0.6.1
4
19
 
5
20
  ### Patch Changes
@@ -3265,6 +3265,10 @@ declare class GessoRuntime {
3265
3265
  private viewportInsetWrite;
3266
3266
  /** Stops watching the app root's environment for a change of registry. */
3267
3267
  private detachViewportInsetEnvironment;
3268
+ /** A WebGPU device being asked for after the last one was lost. */
3269
+ private webgpuRecovery;
3270
+ /** Stops listening for the browser handing back a canvas it had thrown away. */
3271
+ private detachContextRestored;
3268
3272
  private constraints;
3269
3273
  private pixelRatio;
3270
3274
  private lastFrameMs;
@@ -3459,6 +3463,27 @@ declare class GessoRuntime {
3459
3463
  * touch the canvas until it has a device, so the 2D context is free.
3460
3464
  */
3461
3465
  private fallBackToCanvas2D;
3466
+ /**
3467
+ * Asks for a new device for a renderer whose device was lost.
3468
+ *
3469
+ * Not a fall back to Canvas2D, which is what this once did: the
3470
+ * canvas already holds a WebGPU context, `getContext('2d')` on it
3471
+ * answers null, and the fallback threw on every frame from then on.
3472
+ * One request at a time; a failed one is reported, and the next frame
3473
+ * asks again.
3474
+ */
3475
+ private recoverWebGPU;
3476
+ /**
3477
+ * The browser threw the canvas's pixels away and has handed it back
3478
+ * empty. Chrome does this to a canvas in a tab left hidden long
3479
+ * enough to be asked for its memory back, and to every canvas when
3480
+ * the GPU process restarts — which is what a Mac waking from sleep
3481
+ * often does. Nothing in the tree changed, so nothing is dirty and
3482
+ * no frame would ever come: the app sat there as a blank rectangle
3483
+ * until something happened to repaint it. Any layer the renderer
3484
+ * keeps was emptied with it, and reports itself as healthy again.
3485
+ */
3486
+ private surfaceRestored;
3462
3487
  private requestRepaint;
3463
3488
  /**
3464
3489
  * A declared font face finished loading (or failed, which changes
@@ -8294,4 +8319,4 @@ declare class RenderWorkerApp {
8294
8319
  }
8295
8320
  //#endregion
8296
8321
  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 };
8297
- //# sourceMappingURL=index-DidpPgDT.d.ts.map
8322
+ //# sourceMappingURL=index-DWQA6g_M.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-U39HjNFA.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-DidpPgDT.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-DWQA6g_M.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
@@ -6959,6 +6959,10 @@ var GessoRuntime = class {
6959
6959
  viewportInsetWrite = null;
6960
6960
  /** Stops watching the app root's environment for a change of registry. */
6961
6961
  detachViewportInsetEnvironment = null;
6962
+ /** A WebGPU device being asked for after the last one was lost. */
6963
+ webgpuRecovery = null;
6964
+ /** Stops listening for the browser handing back a canvas it had thrown away. */
6965
+ detachContextRestored = null;
6962
6966
  constraints;
6963
6967
  pixelRatio;
6964
6968
  lastFrameMs = 0;
@@ -7132,6 +7136,7 @@ var GessoRuntime = class {
7132
7136
  const webgpu = new WebGPURenderer({
7133
7137
  surface: createWebGPUSurface(options.canvas),
7134
7138
  onError: (message) => this.reportRendererError(message),
7139
+ onLost: () => this.requestRepaint(),
7135
7140
  hooks: {
7136
7141
  onPrepareEnd: (ms) => this.gpuTimings = {
7137
7142
  ...this.gpuTimings ?? emptyGpuTimings(),
@@ -7161,6 +7166,7 @@ var GessoRuntime = class {
7161
7166
  return "canvas2d";
7162
7167
  });
7163
7168
  }
7169
+ this.detachContextRestored = watchContextRestored(this.canvas, () => this.surfaceRestored());
7164
7170
  this.engine = new LayoutEngine(this.textMeasurer);
7165
7171
  this.inspector = new LayoutInspector(this.engine, { modifierNames: (node) => this.builder.modifiersFor(node)?.names ?? [] });
7166
7172
  this.resolver = new ComponentHostResolver(this.services, this.channels);
@@ -7383,6 +7389,42 @@ var GessoRuntime = class {
7383
7389
  this.renderer.resize(this.width, this.height, this.pixelRatio);
7384
7390
  this.requestRepaint();
7385
7391
  }
7392
+ /**
7393
+ * Asks for a new device for a renderer whose device was lost.
7394
+ *
7395
+ * Not a fall back to Canvas2D, which is what this once did: the
7396
+ * canvas already holds a WebGPU context, `getContext('2d')` on it
7397
+ * answers null, and the fallback threw on every frame from then on.
7398
+ * One request at a time; a failed one is reported, and the next frame
7399
+ * asks again.
7400
+ */
7401
+ recoverWebGPU(renderer) {
7402
+ if (this.webgpuRecovery !== null) return;
7403
+ this.webgpuRecovery = renderer.recover().then(() => {
7404
+ if (this.renderer === renderer) {
7405
+ renderer.resize(this.width, this.height, this.pixelRatio);
7406
+ this.requestRepaint();
7407
+ }
7408
+ }).catch((error) => {
7409
+ this.reportRendererError(`WebGPU could not get a new device: ${String(error)}`);
7410
+ }).finally(() => {
7411
+ this.webgpuRecovery = null;
7412
+ });
7413
+ }
7414
+ /**
7415
+ * The browser threw the canvas's pixels away and has handed it back
7416
+ * empty. Chrome does this to a canvas in a tab left hidden long
7417
+ * enough to be asked for its memory back, and to every canvas when
7418
+ * the GPU process restarts — which is what a Mac waking from sleep
7419
+ * often does. Nothing in the tree changed, so nothing is dirty and
7420
+ * no frame would ever come: the app sat there as a blank rectangle
7421
+ * until something happened to repaint it. Any layer the renderer
7422
+ * keeps was emptied with it, and reports itself as healthy again.
7423
+ */
7424
+ surfaceRestored() {
7425
+ this.renderer.surfaceRestored?.();
7426
+ this.requestRepaint();
7427
+ }
7386
7428
  requestRepaint() {
7387
7429
  if (this.root !== void 0) this.graph.markDirty(this.root, DirtyFlags.Paint);
7388
7430
  }
@@ -7734,6 +7776,7 @@ var GessoRuntime = class {
7734
7776
  this.animations.setHidden(!visible);
7735
7777
  if (!visible) return;
7736
7778
  if (!this.started) return;
7779
+ this.surfaceRestored();
7737
7780
  this.scheduler.wake();
7738
7781
  }
7739
7782
  /**
@@ -8209,6 +8252,8 @@ var GessoRuntime = class {
8209
8252
  this.frameListener = null;
8210
8253
  this.input.touchScroll.dispose();
8211
8254
  this.resolver.dispose();
8255
+ this.detachContextRestored?.();
8256
+ this.detachContextRestored = null;
8212
8257
  this.renderer.dispose();
8213
8258
  }
8214
8259
  /**
@@ -9253,7 +9298,7 @@ var GessoRuntime = class {
9253
9298
  this.sendEditingState();
9254
9299
  const rebuildSemantics = frameNeedsSemantics(frame);
9255
9300
  this.phaseTimings.semantics = this.timePhase(() => rebuildSemantics || this.semanticsListener !== null && (laidOut || this.focusManager.focusedNode?.id !== this.lastFocusedId), () => this.updateSemantics(frame, rebuildSemantics, laidOut));
9256
- if (this.renderer.backend === "webgpu" && this.renderer.isLost) this.fallBackToCanvas2D(this.renderer);
9301
+ if (this.renderer.backend === "webgpu" && this.renderer.isLost) this.recoverWebGPU(this.renderer);
9257
9302
  const overlay = this.inspector.hasOverlay ? this.inspector.overlay(started) : null;
9258
9303
  this.gpuTimings = null;
9259
9304
  const changes = this.graph.getDirtyNodes().isEmpty() ? {
@@ -9613,6 +9658,17 @@ function frameChangedTree(frame) {
9613
9658
  function frameNeedsSemantics(frame) {
9614
9659
  return frame.anyFlags(DirtyFlags.Semantics | DirtyFlags.Children);
9615
9660
  }
9661
+ /**
9662
+ * Calls `restored` whenever the browser hands the canvas back after
9663
+ * losing it. Both canvas types are event targets; a test double that is
9664
+ * not one simply never hears.
9665
+ */
9666
+ function watchContextRestored(canvas, restored) {
9667
+ const target = canvas;
9668
+ if (typeof target.addEventListener !== "function" || typeof target.removeEventListener !== "function") return () => {};
9669
+ target.addEventListener("contextrestored", restored);
9670
+ return () => target.removeEventListener?.("contextrestored", restored);
9671
+ }
9616
9672
  //#endregion
9617
9673
  //#region src/app/GessoApp.ts
9618
9674
  /**