ExtensionHost
Source: ExtensionHost.ts:114
Extensions of a renderer. Every renderer has its own host, so two globes on the page have independent extension states. Extensions are activated when the renderer is initialized, so its scenes, the planet too, are already there.
Example
const globe = new Globe({ target: "map", extensions: [hello] });
await globe.extensions.add(other);
// in activate(host)
host.globe?.planet.addLayer(layer);
globe.extensions.get("demo.other").exports;
await globe.extensions.remove("demo.other");Constructor
new ExtensionHost(renderer: Renderer): ExtensionHostParameters
renderer(Renderer) — Renderer.
Instance Methods
init()
add(
extension: IExtension,
options?: IAddExtensionOptions,
): Promise.<IExtensionInfo>
Adds and activates extensions, the promise resolves when they are active. Adding an extension again does nothing.
Parameters
extension(IExtension) — Extension.options(IAddExtensionOptions, optional) — strict doesn't activate an extension built for another openglobus version.
Returns
Promise.<IExtensionInfo>
Example
await globe.extensions.add(hello, { strict: true });load(
src: string | Array.<(string|ILoadItem)>,
options?: ILoadExtensionOptions,
): Promise.<IExtensionInfo>
Loads extension modules at runtime and adds them. Their "@openglobus/og" imports get the og of the app: the og file the app runs, or options.og when og is bundled into the app. Several modules are added together, so they are activated in the order of their requires.
Parameters
src(string | Array.<(string|ILoadItem)>) — Module url or urls.options(ILoadExtensionOptions, optional) — integrity of a single module, og of the app, strict as in add.
Returns
Promise.<IExtensionInfo>
Example
await globe.extensions.load("https://example.com/og-hello/index.js", { integrity: "sha384-..." });
import * as og from "@openglobus/og";
await globe.extensions.load([rulerUrl, { url: profileUrl, integrity: "sha384-..." }], { og });remove(id: string): Promise.<void>
Removes the extension, calls its deactivate.
Parameters
id(string) — Extension id.
Returns
Promise.<void>
has(id: string): boolean
Returns true when the extension is active.
Parameters
id(string) — Extension id.
Returns
boolean
get(id: string): IExtensionInfo | undefined
Returns the extension info, exports is what activate returned.
Parameters
id(string) — Extension id.
Returns
IExtensionInfo | undefined
list(): Array.<IExtensionInfo>
Returns all added extensions.
Returns
Array.<IExtensionInfo>