@companion-surface/base
    Preparing search index...

    Interface SurfacePlugin<TInfo>

    The base SurfacePlugin interface, for all surface plugins

    interface SurfacePlugin<TInfo> {
        checkSupportsHidDevice?: (
            device: HIDDevice,
        ) => DiscoveredSurfaceInfo<TInfo> | null;
        detection?: SurfacePluginDetection<TInfo>;
        openSurface: (
            surfaceId: string,
            pluginInfo: TInfo,
            context: SurfaceContext,
        ) => Promise<OpenSurfaceResult>;
        remote?: SurfacePluginRemote<TInfo>;
        scanForSurfaces?: () => Promise<DetectionSurfaceInfo<TInfo>[]>;
        destroy(): Promise<void>;
        init(): Promise<void>;
    }

    Type Parameters

    • TInfo
    Index

    Properties

    checkSupportsHidDevice?: (
        device: HIDDevice,
    ) => DiscoveredSurfaceInfo<TInfo> | null

    Check if a HID device is supported by this plugin Note: This must not open the device, just perform checks based on the provided info to see if it is supported

    Type Declaration

    Some plugins are forced to use a builtin detection mechanism by their surfaces or inner library In this case, this property should be set to an instance of SurfacePluginDetection

    It is preferred that plugins to NOT use this, and to instead use the abtractions we provide to reduce the cost of scanning and detection Note: it is important that no events are emitted from this until after init() has been invoked, or they will be lost

    openSurface: (
        surfaceId: string,
        pluginInfo: TInfo,
        context: SurfaceContext,
    ) => Promise<OpenSurfaceResult>

    Open a discovered/known surface This can be called for multiple surfaces in parallel

    Type Declaration

    Some plugins can make connections to IP/cloud based surfaces In this case, this property should be set to an instance of SurfacePluginRemote

    Note: it is important that no events are emitted from this until after init() has been invoked, or they will be lost

    scanForSurfaces?: () => Promise<DetectionSurfaceInfo<TInfo>[]>

    Perform a scan for devices, but not open them Note: This should only be used if the plugin uses a protocol where we don't have other handling for

    Methods

    • Uninitialise the plugin

      This will be called once when the plugin is about to be unloaded. You should reset and close any surfaces here, and prepare for being terminated

      Returns Promise<void>