-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.ts
127 lines (113 loc) · 3.86 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* SPDX-FileCopyrightText: 2022 Tim Perry <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/
import {
MockRTC,
MockRTCOptions,
MockRTCPeerBuilder,
MockRTCEvent,
MockRTCEventData,
MockRTCRuleDefinition,
MockRTCSessionDescription,
SelectedRTCCandidate,
TimingEvents
} from "./mockrtc";
import { MockRTCServer } from "./server/mockrtc-server";
import { MockRTCAdminServer } from "./server/mockrtc-admin-server";
export { MockRTCAdminPlugin } from "./server/mockrtc-admin-plugin";
import { MockRTCClient, MockRTCClientOptions } from "./client/mockrtc-client";
// Export the required structures to remotely build and send rules to the admin API:
export * as HandlerStepDefinitions from "./handling/handler-step-definitions";
export * as MatcherDefinitions from "./matching/matcher-definitions";
export { MockRTCAdminRequestBuilder } from "./client/mockrtc-admin-request-builder";
// Re-export lots of types are used in various APIs (mostly to make TypeDoc happy):
export type { HandlerStep } from "./handling/handler-steps";
export type { MockRTCHandlerBuilder } from "./handling/handler-builder";
export type { MockRTCRuleBuilder, RuleHandlerBuilder } from "./rule-builder";
export type { MockRTCServerPeer } from "./server/mockrtc-server-peer";
export type { SessionData } from "./server/mockrtc-admin-plugin";
export type { RTCConnection, ParsedSDP } from "./webrtc/rtc-connection";
export type { MockRTCConnection } from "./webrtc/mockrtc-connection";
export type { DataChannelStream } from "./webrtc/datachannel-stream";
export type { MediaTrackStream } from "./webrtc/mediatrack-stream";
export type { PluggableAdmin } from 'mockttp';
export type {
MockRTC,
MockRTCOptions,
MockRTCClientOptions,
MockRTCPeerBuilder,
MockRTCAdminServer,
MockRTCEvent,
MockRTCEventData,
MockRTCRuleDefinition,
MockRTCSessionDescription,
SelectedRTCCandidate,
TimingEvents
};
export type {
MockRTCPeer,
MockRTCPeerOptions,
MockRTCSession,
MockRTCOfferParams,
MockRTCAnswerParams,
MockRTCExternalOfferParams,
MockRTCExternalAnswerParams,
OfferOptions,
AnswerOptions,
ConnectionMetadata
} from './mockrtc-peer';
export {
MOCKRTC_CONTROL_CHANNEL,
type MockRTCControlMessage
} from './webrtc/control-channel';
export {
hookWebRTCConnection,
hookAllWebRTC
} from "./webrtc-hooks";
/**
* Get a MockRTC instance on the local machine.
*
* In most simple environments, you can call this method directly and immediately
* get a MockRTC instance and start mocking peers.
*
* In node, the mocked peers will run in process and require no further setup.
*
* In browsers this is an alias for {@link getRemote}. You'll need to start a MockRTC
* admin server outside your tests before calling this, which will create and manage
* your fake peers outside the browser.
*
* @category API
*/
export function getLocal(): MockRTC {
return new MockRTCServer();
}
/**
* Get a MockRTC instance, managed by a MockRTC admin server running elsewhere.
*
* This connects to a MockRTC server, and uses that to start
* and stop mock peers.
*
* @category API
*/
export function getRemote(options: MockRTCClientOptions = {}): MockRTC {
return new MockRTCClient(options);
}
/**
* Get a MockRTC admin server, which can be used with a MockRTC remote client to create
* & manage mock peers either from remote machines or from local environments
* that lack necessary capabilities, e.g. to use MockRTC from inside a browser.
*
* This function exists so you can set up these servers programmatically, but for most
* usage you can just run your tests via the `mockrtc` binary, which will automatically
* start and stop an admin server for you:
*
* ```
* mockrtc -c <your test command>
* ```
*
* @category API
*/
export function getAdminServer(): MockRTCAdminServer {
return new MockRTCAdminServer();
}