import { createDebug } from './debug.js'; import type { EventsContract } from '@mnjs/utils'; import type { Requests as RequestsContract } from './requests.js'; export interface Channel extends EventsContract, RequestsContract { channelName: string; reset(): this; } declare const channelContract: Channel; type ChannelMethods = { on: typeof channelContract.on; once: typeof channelContract.once; off: typeof channelContract.off; listenTo: typeof channelContract.listenTo; listenToOnce: typeof channelContract.listenToOnce; stopListening: typeof channelContract.stopListening; trigger: typeof channelContract.trigger; triggerMethod: Channel['triggerMethod']; reply: typeof channelContract.reply; replyOnce: typeof channelContract.replyOnce; stopReplying: typeof channelContract.stopReplying; request: Channel['request']; }; type Forward = Method extends { (...args: infer FirstArgs): infer FirstResult; (...args: infer LastArgs): infer LastResult; } ? { (channelName: string, ...args: FirstArgs): FirstResult; (channelName: string, ...args: LastArgs): LastResult; } : never; type ForwardedMethods = { [Method in keyof ChannelMethods]: Forward; }; export interface RadioApi extends ForwardedMethods { setDebug: ReturnType['setDebug']; log: ReturnType['hooks']['log']; debugLog: ReturnType['hooks']['debugLog']; Channel: ChannelConstructor; channel(name: string): Channel; reset(): void; reset(name: string): void; tuneIn(name: string): RadioApi; tuneOut(name: string): RadioApi; } export type ChannelConstructor = { new (channelName: string): Channel; prototype: Channel; }; export declare function createRadio(): RadioApi; declare const Radio: RadioApi; export declare const Channel: ChannelConstructor; export default Radio;