import { Replicant, ReplicantOptions, DeclaredReplicants, ReplicantBrowser, } from './replicant'; import {NodeCG} from './nodecg-instance'; import {Platform} from './platform'; /** * NodeCG constructor */ interface NodeCGStaticCommon

> { new (bundle: any, socket: SocketIOClient.Socket): NodeCG

; version: string; sendMessageToBundle: SendMessageToBundle

; declaredReplicants: DeclaredReplicants

; Replicant(name: string, opts?: ReplicantOptions): Replicant; Replicant( name: string, namespace?: string, opts?: ReplicantOptions ): Replicant; } /** * NodeCG constructor in extensions */ export interface NodeCGStaticServer extends NodeCGStaticCommon<'server'> { readReplicant(name: string, namespace?: string): void; } /** * NodeCG constructor in browser */ export interface NodeCGStaticBrowser extends NodeCGStaticCommon<'browser'> { readReplicant(name: string, cb: (value: V) => void): void; readReplicant( name: string, namespace: string, cb: (value: V) => void ): void; waitForReplicants(...replicants: ReplicantBrowser[]): Promise; } /** * NodeCG constructor combined */ export type NodeCGStatic

= P extends 'server' ? NodeCGStaticServer : NodeCGStaticBrowser; /** * sendMessage returns Promise in browser, void in extensions */ type SendMessageReturnType

= P extends 'server' ? void : Promise; /** * Combined 'sendMessageToBundle' method for browser and extensions */ interface SendMessageToBundle< P extends Platform, M = SendMessageReturnType

> { ( messageName: string, bundleName: string, cb?: (error: any, ...args: any[]) => void ): M; ( messageName: string, bundleName: string, data: any, cb?: (error: any, ...args: any[]) => void ): M; }