gesso-framework 0.6.2 → 0.6.4

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,9 +1,25 @@
1
1
  # gesso-framework
2
2
 
3
+ ## 0.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 2f6a858: The `history` option now also takes a ready-made `ShellHistory`, for an app embedded in a page whose address bar belongs to its host. An app in an iframe inside another product, such as an Atlassian Forge Custom UI app in Jira, can reach the host's address only through a history object the host hands out. Adapt that object to `ShellHistory` and pass it to `createApp`, `createSyncApp(...).useHistory` or `GessoApp` in place of `{ mode }`, and the router reads its starting url from it, pushes and replaces through it, and follows the changes it reports. A history passed in stays the caller's: disposing the app stops listening to it but does not dispose it, so it survives a remount. Options work exactly as before.
8
+ - gesso-core@0.6.4
9
+
10
+ ## 0.6.3
11
+
12
+ ### Patch Changes
13
+
14
+ - 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.
15
+ - Updated dependencies
16
+ - gesso-core@0.6.3
17
+
3
18
  ## 0.6.2
4
19
 
5
20
  ### Patch Changes
6
21
 
22
+ - 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.
7
23
  - gesso-core@0.6.2
8
24
 
9
25
  ## 0.6.1
@@ -3265,6 +3265,8 @@ 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;
3268
3270
  /** Stops listening for the browser handing back a canvas it had thrown away. */
3269
3271
  private detachContextRestored;
3270
3272
  private constraints;
@@ -3461,6 +3463,16 @@ declare class GessoRuntime {
3461
3463
  * touch the canvas until it has a device, so the 2D context is free.
3462
3464
  */
3463
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;
3464
3476
  /**
3465
3477
  * The browser threw the canvas's pixels away and has handed it back
3466
3478
  * empty. Chrome does this to a canvas in a tab left hidden long
@@ -5314,6 +5326,18 @@ interface ShellHistoryOptions {
5314
5326
  /** `memory` mode only: where the app starts. Defaults to `/`. */
5315
5327
  readonly initialUrl?: string;
5316
5328
  }
5329
+ /**
5330
+ * A url kept somewhere, which the shell reads, writes and listens to.
5331
+ *
5332
+ * `createShellHistory` makes one from `ShellHistoryOptions`, and that
5333
+ * covers every window the app owns the address of. An app embedded in
5334
+ * a page whose address belongs to something else does not own it: an
5335
+ * Atlassian Forge Custom UI app runs in an iframe inside Jira, and the
5336
+ * only way to Jira's address bar is the history object Forge's bridge
5337
+ * hands out. Such a host implements this interface over whatever it
5338
+ * has, and passes the object as the app's `history` option in place of
5339
+ * options, so the router and the host's address bar stay one url.
5340
+ */
5317
5341
  interface ShellHistory {
5318
5342
  /** The url the window is at now. */
5319
5343
  readonly url: string;
@@ -5321,7 +5345,14 @@ interface ShellHistory {
5321
5345
  replace(url: string): void;
5322
5346
  back(): void;
5323
5347
  forward(): void;
5324
- /** Reports urls the person produced: back, forward, or a typed address. */
5348
+ /**
5349
+ * Reports urls the person produced: back, forward, or a typed address.
5350
+ *
5351
+ * There is one listener, and a second call replaces the first. An
5352
+ * app that was handed its history and is being taken down relies on
5353
+ * that to stop listening, since disposing a history it did not make
5354
+ * is not its decision.
5355
+ */
5325
5356
  onChange(listener: (url: string) => void): void;
5326
5357
  dispose(): void;
5327
5358
  }
@@ -5558,8 +5589,18 @@ interface WorkerAppOptions {
5558
5589
  * routes, resolves nothing, and could not — a route names a
5559
5590
  * component class, which never leaves the worker. It reports the url
5560
5591
  * the window is at and performs the pushes the worker asks for.
5592
+ *
5593
+ * Or a `ShellHistory` made elsewhere, for a page whose address the
5594
+ * app does not own. An app embedded in another product — an
5595
+ * Atlassian Forge Custom UI app is an iframe inside Jira — reaches
5596
+ * the address bar only through the history object its host hands
5597
+ * out, so it adapts that object to `ShellHistory` and passes it here,
5598
+ * and the router and the host's address stay one url. A history
5599
+ * passed this way is used as it is and survives the app: unmount
5600
+ * stops listening to it but does not dispose it, by the rule
5601
+ * `appLogicWorker` follows, and a remount picks the same one up.
5561
5602
  */
5562
- history?: ShellHistoryOptions;
5603
+ history?: ShellHistoryOptions | ShellHistory;
5563
5604
  }
5564
5605
  declare class WorkerApp {
5565
5606
  private readonly options;
@@ -5592,6 +5633,8 @@ declare class WorkerApp {
5592
5633
  */
5593
5634
  private scrollability;
5594
5635
  private history;
5636
+ /** True only when the history was made here from options; see `resolveShellHistory`. */
5637
+ private ownsHistory;
5595
5638
  /** True once the render worker has answered `ready` at least once. */
5596
5639
  private ready;
5597
5640
  /** The running `requestAnimationFrame` handle, when ticks are wanted. */
@@ -6014,8 +6057,11 @@ declare class GessoAppBuilder {
6014
6057
  /**
6015
6058
  * How the app's url is kept: `path` (pushState, the default in a
6016
6059
  * browser), `hash`, or `memory`. See `shellHistory`.
6060
+ *
6061
+ * Or a `ShellHistory` made elsewhere, for an app embedded in a page
6062
+ * whose address belongs to its host; see `GessoAppOptions.history`.
6017
6063
  */
6018
- useHistory(history: ShellHistoryOptions): this;
6064
+ useHistory(history: ShellHistoryOptions | ShellHistory): this;
6019
6065
  /**
6020
6066
  * Pins the rendering backend. Without this the app is on `auto`:
6021
6067
  * WebGPU where the browser has it, Canvas2D elsewhere.
@@ -6140,8 +6186,14 @@ interface GessoAppOptions {
6140
6186
  /**
6141
6187
  * How the app's url is kept: `path` (pushState, the default in a
6142
6188
  * browser), `hash`, or `memory`. See `shellHistory`.
6189
+ *
6190
+ * Or a `ShellHistory` made elsewhere, for a page whose address the
6191
+ * app does not own: an iframe inside another product, where the
6192
+ * host's own history object is the only way to its address bar. It
6193
+ * is used as it is, and left undisposed when the app is disposed,
6194
+ * because it belongs to whoever passed it.
6143
6195
  */
6144
- history?: ShellHistoryOptions;
6196
+ history?: ShellHistoryOptions | ShellHistory;
6145
6197
  canvas?: CanvasHost;
6146
6198
  /** The rendering backend; see RendererChoice. Defaults to `auto`. */
6147
6199
  renderer?: RendererChoice;
@@ -6218,6 +6270,8 @@ declare class GessoApp {
6218
6270
  private audio;
6219
6271
  private mirror;
6220
6272
  private history;
6273
+ /** True only when the history was made here from options; see `resolveShellHistory`. */
6274
+ private ownsHistory;
6221
6275
  private detachVisibility;
6222
6276
  private detachFileDrop;
6223
6277
  /** Pickers and remembered handles, made on the first file request. */
@@ -8307,4 +8361,4 @@ declare class RenderWorkerApp {
8307
8361
  }
8308
8362
  //#endregion
8309
8363
  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 };
8310
- //# sourceMappingURL=index-CmRQJWpn.d.ts.map
8364
+ //# sourceMappingURL=index-BvaYnj-Q.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-CmRQJWpn.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-BvaYnj-Q.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
@@ -3761,6 +3761,51 @@ function createShellHistory(options = {}, host = typeof window === "undefined" ?
3761
3761
  if (mode === "memory" || host === void 0) return new MemoryHistory(options.initialUrl ?? "/");
3762
3762
  return new BrowserHistory(host, mode, options.base ?? "");
3763
3763
  }
3764
+ /**
3765
+ * The history an app runs against, and whether the app may dispose it.
3766
+ *
3767
+ * Options are turned into a history here, and that history is the
3768
+ * app's to dispose with everything else it made. A history passed in
3769
+ * ready-made is used as it is and left alone at the end, by the rule
3770
+ * `appLogicWorker` already follows: what the app made, it disposes;
3771
+ * what it was handed, it leaves to whoever handed it. That is also
3772
+ * what keeps a host's history alive across a remount, which disposes
3773
+ * the app and builds it again around the same object.
3774
+ */
3775
+ function resolveShellHistory(source) {
3776
+ if (isShellHistory(source)) return {
3777
+ history: source,
3778
+ owned: false
3779
+ };
3780
+ return {
3781
+ history: createShellHistory(source),
3782
+ owned: true
3783
+ };
3784
+ }
3785
+ /**
3786
+ * Tells a ready-made history from options by its methods.
3787
+ *
3788
+ * Options are plain data and never carry a function, so the presence of
3789
+ * `push` and `onChange` as functions is unambiguous. It is checked by
3790
+ * behaviour rather than by `instanceof` because the histories worth
3791
+ * passing are adapters an embedder wrote, not classes from here.
3792
+ */
3793
+ function isShellHistory(value) {
3794
+ return value !== void 0 && typeof value.push === "function" && typeof value.onChange === "function";
3795
+ }
3796
+ /**
3797
+ * Stops an app hearing about a history it is done with.
3798
+ *
3799
+ * A history the app made is disposed, which drops its listeners and
3800
+ * its window events with it. One it was handed is not the app's to
3801
+ * dispose, so the listener is replaced with one that does nothing:
3802
+ * the host's history goes on working, and a back button pressed after
3803
+ * the app is gone no longer reaches it.
3804
+ */
3805
+ function releaseShellHistory(history, owned) {
3806
+ if (owned) history.dispose();
3807
+ else history.onChange(() => {});
3808
+ }
3764
3809
  var MemoryHistory = class {
3765
3810
  entries;
3766
3811
  index = 0;
@@ -4078,6 +4123,8 @@ var WorkerApp = class {
4078
4123
  right: false
4079
4124
  };
4080
4125
  history = null;
4126
+ /** True only when the history was made here from options; see `resolveShellHistory`. */
4127
+ ownsHistory = false;
4081
4128
  /** True once the render worker has answered `ready` at least once. */
4082
4129
  ready = false;
4083
4130
  /** The running `requestAnimationFrame` handle, when ticks are wanted. */
@@ -4439,8 +4486,9 @@ var WorkerApp = class {
4439
4486
  this.proxy = null;
4440
4487
  this.mirror?.dispose();
4441
4488
  this.mirror = null;
4442
- this.history?.dispose();
4489
+ if (this.history !== null) releaseShellHistory(this.history, this.ownsHistory);
4443
4490
  this.history = null;
4491
+ this.ownsHistory = false;
4444
4492
  this.detachInput?.();
4445
4493
  this.detachInput = null;
4446
4494
  this.audio?.dispose();
@@ -4595,8 +4643,9 @@ var WorkerApp = class {
4595
4643
  * the screen that url names, not on its root.
4596
4644
  */
4597
4645
  attachHistory() {
4598
- const history = createShellHistory(this.options.history);
4646
+ const { history, owned } = resolveShellHistory(this.options.history);
4599
4647
  this.history = history;
4648
+ this.ownsHistory = owned;
4600
4649
  history.onChange((url) => this.post({
4601
4650
  type: "url",
4602
4651
  url
@@ -6959,6 +7008,8 @@ var GessoRuntime = class {
6959
7008
  viewportInsetWrite = null;
6960
7009
  /** Stops watching the app root's environment for a change of registry. */
6961
7010
  detachViewportInsetEnvironment = null;
7011
+ /** A WebGPU device being asked for after the last one was lost. */
7012
+ webgpuRecovery = null;
6962
7013
  /** Stops listening for the browser handing back a canvas it had thrown away. */
6963
7014
  detachContextRestored = null;
6964
7015
  constraints;
@@ -7134,6 +7185,7 @@ var GessoRuntime = class {
7134
7185
  const webgpu = new WebGPURenderer({
7135
7186
  surface: createWebGPUSurface(options.canvas),
7136
7187
  onError: (message) => this.reportRendererError(message),
7188
+ onLost: () => this.requestRepaint(),
7137
7189
  hooks: {
7138
7190
  onPrepareEnd: (ms) => this.gpuTimings = {
7139
7191
  ...this.gpuTimings ?? emptyGpuTimings(),
@@ -7387,6 +7439,28 @@ var GessoRuntime = class {
7387
7439
  this.requestRepaint();
7388
7440
  }
7389
7441
  /**
7442
+ * Asks for a new device for a renderer whose device was lost.
7443
+ *
7444
+ * Not a fall back to Canvas2D, which is what this once did: the
7445
+ * canvas already holds a WebGPU context, `getContext('2d')` on it
7446
+ * answers null, and the fallback threw on every frame from then on.
7447
+ * One request at a time; a failed one is reported, and the next frame
7448
+ * asks again.
7449
+ */
7450
+ recoverWebGPU(renderer) {
7451
+ if (this.webgpuRecovery !== null) return;
7452
+ this.webgpuRecovery = renderer.recover().then(() => {
7453
+ if (this.renderer === renderer) {
7454
+ renderer.resize(this.width, this.height, this.pixelRatio);
7455
+ this.requestRepaint();
7456
+ }
7457
+ }).catch((error) => {
7458
+ this.reportRendererError(`WebGPU could not get a new device: ${String(error)}`);
7459
+ }).finally(() => {
7460
+ this.webgpuRecovery = null;
7461
+ });
7462
+ }
7463
+ /**
7390
7464
  * The browser threw the canvas's pixels away and has handed it back
7391
7465
  * empty. Chrome does this to a canvas in a tab left hidden long
7392
7466
  * enough to be asked for its memory back, and to every canvas when
@@ -9273,7 +9347,7 @@ var GessoRuntime = class {
9273
9347
  this.sendEditingState();
9274
9348
  const rebuildSemantics = frameNeedsSemantics(frame);
9275
9349
  this.phaseTimings.semantics = this.timePhase(() => rebuildSemantics || this.semanticsListener !== null && (laidOut || this.focusManager.focusedNode?.id !== this.lastFocusedId), () => this.updateSemantics(frame, rebuildSemantics, laidOut));
9276
- if (this.renderer.backend === "webgpu" && this.renderer.isLost) this.fallBackToCanvas2D(this.renderer);
9350
+ if (this.renderer.backend === "webgpu" && this.renderer.isLost) this.recoverWebGPU(this.renderer);
9277
9351
  const overlay = this.inspector.hasOverlay ? this.inspector.overlay(started) : null;
9278
9352
  this.gpuTimings = null;
9279
9353
  const changes = this.graph.getDirtyNodes().isEmpty() ? {
@@ -9683,6 +9757,8 @@ var GessoApp = class {
9683
9757
  audio = null;
9684
9758
  mirror = null;
9685
9759
  history = null;
9760
+ /** True only when the history was made here from options; see `resolveShellHistory`. */
9761
+ ownsHistory = false;
9686
9762
  detachVisibility = null;
9687
9763
  detachFileDrop = null;
9688
9764
  /** Pickers and remembered handles, made on the first file request. */
@@ -9906,8 +9982,9 @@ var GessoApp = class {
9906
9982
  this.detachColorScheme = null;
9907
9983
  this.detachViewportInsets?.();
9908
9984
  this.detachViewportInsets = null;
9909
- this.history?.dispose();
9985
+ if (this.history !== null) releaseShellHistory(this.history, this.ownsHistory);
9910
9986
  this.history = null;
9987
+ this.ownsHistory = false;
9911
9988
  this.adapter.detach();
9912
9989
  this.resizeObserver?.disconnect();
9913
9990
  this.resizeObserver = null;
@@ -9989,8 +10066,9 @@ var GessoApp = class {
9989
10066
  * be a difference between the two hosts that nothing declared.
9990
10067
  */
9991
10068
  attachHistory() {
9992
- const history = createShellHistory(this.historyOptions);
10069
+ const { history, owned } = resolveShellHistory(this.historyOptions);
9993
10070
  this.history = history;
10071
+ this.ownsHistory = owned;
9994
10072
  this.runtime.onShellRequest((request) => this.handleShellRequest(request, history));
9995
10073
  history.onChange((url) => this.runtime.setUrl(url));
9996
10074
  this.runtime.setUrl(history.url);
@@ -10179,6 +10257,9 @@ var GessoAppBuilder = class {
10179
10257
  /**
10180
10258
  * How the app's url is kept: `path` (pushState, the default in a
10181
10259
  * browser), `hash`, or `memory`. See `shellHistory`.
10260
+ *
10261
+ * Or a `ShellHistory` made elsewhere, for an app embedded in a page
10262
+ * whose address belongs to its host; see `GessoAppOptions.history`.
10182
10263
  */
10183
10264
  useHistory(history) {
10184
10265
  this.historyOptions = history;