import { StandardError } from "../../../types"; export type IncomingTransportInfo = { port?: number; transportID: AvailableTransports; lastClient: string; origin: string; }; export type RouterHeader = { channel: string; origin: string; incomingTransportInfo: IncomingTransportInfo; lastClient: string; type: string; topic?: string; subscribeID?: string; queryID?: string; handleOnServer?: boolean; originMetadata: ConnectionMetadata; timeout?: number; }; export interface RouterResponse { data: T; header: RouterHeader; } export interface RouterMessage extends RouterResponse { options: { suppressWarnings: boolean; }; originatedHere(): boolean; } export type RouterTransportSettings = { FinsembleTransport?: { serverAddress?: string; }; }; export type RouterConfig = { windowName: string; transportSettings?: RouterTransportSettings; /** * Only required for shared worker */ routerDomainRoot?: string; /** * Which transport to enable. Use Startup/RouterConfig.getRecommendedTransport() Set this to "FinsembleTransport" when in freestanding mode. */ transportName: string; }; /** * Call this to unsubscribe to a prior listener call. */ export type RouterListenerUnsubscribe = () => void; export type SendToRouter = { header: { origin: string; type: string; [key: string]: any; }; }; export type TransmitMessage = SendToRouter & { header: { type: "transmit"; channel: string; }; data: T; options?: { suppressWarnings: boolean; }; }; export type TransmitMessageFromService = RouterMessage & TransmitMessage; export type ListenerResponse = TransmitMessageFromService & { originatedHere: () => void; }; export type ListenerCallback = (err: null | string, response: ListenerResponse) => void; export interface QueryMessage extends SendToRouter { header: { origin: string; type: "query"; queryID: string; channel: string; logWhenNoResponder: boolean; error?: string | null; timeout: number; }; data: T; } export type QueryMessageFromService = RouterMessage & QueryMessage; /** * Q = type of query (sent by client call to query() ) * R = type of response (returned by server call to sendQueryResponse() ) */ export type ResponderMessage = QueryMessageFromService & { sendQueryResponse(error: StandardError, data?: R): any; originatedHere: () => void; }; export type QueryResponseMessage = SendToRouter & { header: { type: "queryResponse"; queryID: string; error?: string | null; }; data?: T; }; export type QueryResponseFromService = RouterMessage & QueryResponseMessage; export type QueryResponse = { data?: T; header: RouterHeader; }; export type QueryResponseCallback = (err: null | string, response: QueryResponse) => void; export type StandardQueryResponse = { err?: null | string; response: QueryResponse; }; export interface RemoveResponderMessage extends SendToRouter { header: { origin: string; type: "removeResponder"; channel: string; }; } /** Section: subscribe() / addPubSubResponder() / removePubSubResponder() */ export interface SubscribeMessage extends SendToRouter { header: { origin: string; type: "subscribe"; subscribeID: string; topic: string; error?: string | null; }; } export type SubscribeMessageFromService = RouterMessage & SubscribeMessage; export type SubscribeHookMessage = SubscribeMessageFromService & { sendNotifyToSubscriber: (err: string | null, data?: T) => void; }; export type SubscriberResponse = SendToRouter & { header: { topic: string; subscribeID: string; error?: string | null; }; data: T; originatedHere: () => boolean; }; export interface UnsubscribeMessage extends SendToRouter { header: { origin: string; type: "unsubscribe"; subscribeID: string; topic: string; }; } export type UnsubscribeMessageFromService = RouterMessage & UnsubscribeMessage; export type UnsubscribeHookMessage = UnsubscribeMessageFromService & { removeSubscriber: () => void; }; export interface PublishMessage extends SendToRouter { header: { origin: string; type: "publish"; topic: string; }; data: T; } export type PublishMessageFromService = RouterMessage & PublishMessage; export type PublishHookMessage = PublishMessageFromService & { sendNotifyToAllSubscribers: (err: string | null, data: T) => void; }; export type NotifyMessage = SendToRouter & { header: { type: "notify"; subscribeID: string; topic: string; error?: string; }; data: T; }; export type NotifyMessageFromService = RouterMessage & NotifyMessage; export type NotifyCallback = (err: StandardError, response: SubscriberResponse) => void; export type SubscribeCallback = (err: null | string, data: SubscribeHookMessage) => void; export type UnsubscribeCallback = (err: null | string, data: UnsubscribeHookMessage) => void; export type PublishCallback = (err: null | string, data: PublishHookMessage) => void; export type IPCTransportInfo = { name: string; transportID: "IPCBus"; }; export type SharedWorkerTransportInfo = { port: number; transportID: "SharedWorker"; }; export type IACTransportInfo = { client: string; transportID: "FinsembleTransport"; }; export type AvailableTransports = IPCTransportInfo["transportID"] | SharedWorkerTransportInfo["transportID"] | IACTransportInfo["transportID"]; export type TransportInfo = { transportID: AvailableTransports; port?: number; name?: string; client?: string; }; /** * Metadata associated with the remote router client. This data is added to the header for all outbound packets so * that receiving apps have information about the sending app. Currently, this information is _deduced_ from the * `origin` field and is therefore not appropriate for high security applications. In future revisions, this information * will be provided by the WindowService via a back-channel which will make it more secure. * * This object is attached to outbound router message headers. Don't put anything large in this object. */ export type ConnectionMetadata = { routerConnectionId: string; transportInfo: TransportInfo; windowName: string; appId: string | null; webContentsName: string | null; }; //# sourceMappingURL=types.d.ts.map