Skip to content

Commit

Permalink
Add missing types
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoishin committed Jun 8, 2019
1 parent 999d435 commit 7e49cd6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
36 changes: 33 additions & 3 deletions browser.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import {NodeCG} from './helper/nodecg';
import {ReplicantMap} from './helper/replicant';
import {MessageMap} from './helper/message';
import {
ReplicantMap,
ReplicantFactory,
ReadReplicant,
WaitForReplicants,
} from './helper/replicant';
import {
MessageMap,
SendMessageToBundleBrowser,
SendMessageToBundle,
} from './helper/message';

interface Cue {
name: string;
Expand Down Expand Up @@ -44,7 +53,8 @@ export type CreateNodecgConstructor<
TBundleConfig extends {},
TBundleName extends string,
TReplicantMap extends ReplicantMap,
TMessageMap extends MessageMap
TMessageMap extends MessageMap,
TForOthers extends boolean = false
> = {
new (bundle: unknown, socket: SocketIOClient.Socket): CreateNodecgInstance<
TBundleConfig,
Expand All @@ -53,4 +63,24 @@ export type CreateNodecgConstructor<
TMessageMap
>;
version: string;

sendMessageToBundle: SendMessageToBundle<
TMessageMap,
'browser',
TBundleName
>;

Replicant: ReplicantFactory<
TBundleName,
TReplicantMap,
'browser',
TForOthers
>;
readReplicant: ReadReplicant<
'browser',
TForOthers,
TReplicantMap,
TBundleName
>;
waitForReplicants: WaitForReplicants<TReplicantMap, TBundleName, 'browser'>;
};
13 changes: 13 additions & 0 deletions helper/replicant.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,16 @@ export type ReplicantFactory<
| [TBundleName, ReplicantOptions<TRepMap[TRepName]>?]
| [ReplicantOptions<TRepMap[TRepName]>?])
) => Replicant<TRepMap[TRepName], TRepName, TBundleName, TPlatform>;

export type WaitForReplicants<
TRepMap extends ReplicantMap,
TBundleName extends string,
TPlatform extends Platform
> = (
...replicants: Replicant<
TRepMap[keyof TRepMap],
keyof TRepMap,
TBundleName,
TPlatform
>[]
) => Promise<void>;

0 comments on commit 7e49cd6

Please sign in to comment.