@intisy/bayonet
    Preparing search index...

    Interface PluginContext

    Everything a plugin may touch, and the only way it touches any of it.

    Taking everything through the context is what makes the introspection ledger and the doctor free rather than separately built, and it is the seam a host would use to run a plugin out of process without changing plugin code.

    interface PluginContext {
        config: PluginConfig;
        events: Events;
        host: HostDescriptor;
        log: Logger;
        manifest: PluginManifest;
        paths: PluginPaths;
        services: Services;
        capability<T>(id: string): CapabilityType<T>;
        homes(): HomeDescriptor[];
        provide<T>(type: CapabilityType<T>, implementation: T): void;
        service<T>(id: string): ServiceType<T>;
        topic<T>(id: string): TopicType<T>;
    }
    Index
    config: PluginConfig

    This plugin's resolved configuration.

    events: Events

    How this plugin says something happened, and hears that something did.

    What this plugin may know about the host.

    log: Logger

    This plugin's logger.

    manifest: PluginManifest

    This plugin's own manifest, as the host validated it.

    The storage directories of the home this plugin runs in.

    services: Services

    How this plugin reaches another plugin's API, and offers its own.

    • The typed key for a capability id, so a plugin can provide one without linking the library that mints it.

      Type Parameters

      • T

        the capability's implementation type

      Parameters

      • id: string

        the capability id, as the manifest declares it

      Returns CapabilityType<T>

      the typed key for that id

      The id is data the manifest already states, and the payload type comes from a type-only import, which erases at build time. That pair is what makes a plugin's only runtime dependency this package.

    • Every app home the host knows about, whether or not each exists on disk.

      Returns HomeDescriptor[]

      every app home the host knows about

      Asked rather than held, because a home can appear, and can be installed, while a plugin is running. paths is this plugin's own home; this is every home there is.

    • Supplies the implementation behind a capability the manifest declares.

      Type Parameters

      • T

        the capability's implementation type

      Parameters

      • type: CapabilityType<T>

        the capability key, from capability(String)

      • implementation: T

        this plugin's implementation of that capability

      Returns void

      One signature, never a plain-string overload beside it: the pair would let a wrong payload compile through the string side.

    • The typed key for a service id, so a plugin can reach another's API, or offer its own, without linking the library that mints the id.

      Type Parameters

      • T

        the service's API type

      Parameters

      • id: string

        the service id, as the manifest declares it

      Returns ServiceType<T>

      the typed key for that id

      The counterpart of capability(String) for the ids a manifest states under services. Without it a plugin would have to write the key literal itself, which is the plugin minting vocabulary rather than naming an id it already declares.

    • The typed key for an event topic, so a plugin can publish or subscribe without linking the library that names the topic.

      Type Parameters

      • T

        the topic's payload type

      Parameters

      • id: string

        the topic id, as the manifest declares it

      Returns TopicType<T>

      the typed key for that id

      Same reason as service(String): a topic is an id, and a plugin that had to build the key by hand would be minting the vocabulary instead of naming it.