Files
gods-eye-view/src/render/applicationHooks.js
T
Sameh Khamis 16c7034c28 Show the renderer's credits in the application's own line
- On a renderer whose plugin does not show its credits in a display of
  its own (the ownCreditDisplay hook; Cesium's does), the application
  shows what the credits port lists at the bottom left (#gev-credits):
  inline credits on the line, the rest, the layers' data credits among
  them, in the Data attribution list it opens. The button and list are
  keyboard operable; Escape closes the list and returns focus. Text is set
  as text; links and logos keep only safe schemes.
- The panel, Cockpit and overlay layouts keep clear of it as of Cesium's.
- The stub boot check fails when the credits line is not shown or its list
  is empty; it keeps its report when the run stops early, counts only the
  dev server's providers and other origins as feeds, and a failed default
  renderer load is retried without dropping a newer one.
2026-11-10 18:29:47 -08:00

47 lines
2.0 KiB
JavaScript

/**
* @module render/applicationHooks
* @description What a renderer's plugin may hand the application beside the
* contract: behaviour the application uses where a renderer has it, and does
* without where it has none. Nothing here is part of the renderer contract,
* and the application never asks which renderer it runs on: it reads the
* hooks of the renderer it was given, each of them optional.
*
* - `mapEngine`: the renderer's own map engine (`src/maps/engine.js`), which
* the map stacks switch through in place of the globe port
* (`src/maps/globeEngine.js`).
* - `trimStaleCommands()`: drops the draw commands a renderer keeps for a
* while after it stops drawing them; run after a layer turns off.
* - `keepPanelRendering(options)`: keeps the globe drawing in an inline panel
* whose host stops animation frames (embed mode); returns its disposer.
* - `viewerDrawsEntity(entity)`: whether an entity is one the renderer draws
* itself (Cockpit asks whether the aircraft it flies still draws).
* - `installZoomOutGuard(options)`: keeps outward user zooms bounded and the
* Earth framed; returns its disposer.
* - `qaHandles`: values QA scripts read from `window.__godsEyeView`.
* - `ownCreditDisplay`: true when the renderer shows its credits in a
* display of its own; otherwise the application shows what its credits
* port lists (`src/ui/creditsView.js`).
*/
const hooks = new WeakMap();
const NONE = Object.freeze({});
/**
* Hand the application `value`'s hooks for `renderer`. A renderer's plugin
* calls it as it creates the renderer; a later call replaces them.
* @param {object} renderer
* @param {object} value
*/
export function provideApplicationHooks(renderer, value) {
hooks.set(renderer, Object.freeze({ ...value }));
}
/**
* The hooks `renderer`'s plugin provided; an empty object when it provided
* none, or `renderer` is not an object.
* @param {object|null|undefined} renderer
* @returns {Readonly<object>}
*/
export const applicationHooksOf = (renderer) =>
(renderer && hooks.get(renderer)) || NONE;