mockrtc 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/.github/workflows/ci.yml +99 -8
  2. package/README.md +1 -9
  3. package/dist/client/mockrtc-client.d.ts +1 -1
  4. package/dist/client/mockrtc-remote-peer.d.ts +1 -0
  5. package/dist/handling/handler-builder.d.ts +1 -0
  6. package/dist/handling/handler-builder.js +13 -13
  7. package/dist/handling/handler-builder.js.map +1 -1
  8. package/dist/handling/handler-step-definitions.d.ts +39 -24
  9. package/dist/handling/handler-step-definitions.js +47 -34
  10. package/dist/handling/handler-step-definitions.js.map +1 -1
  11. package/dist/handling/handler-step-impls.d.ts +56 -0
  12. package/dist/handling/{handler-steps.js → handler-step-impls.js} +39 -46
  13. package/dist/handling/handler-step-impls.js.map +1 -0
  14. package/dist/main-browser.d.ts +2 -2
  15. package/dist/main-browser.js +3 -3
  16. package/dist/main-browser.js.map +1 -1
  17. package/dist/main.d.ts +3 -3
  18. package/dist/main.js +3 -3
  19. package/dist/main.js.map +1 -1
  20. package/dist/matching/matcher-definitions.d.ts +15 -15
  21. package/dist/matching/matcher-definitions.js +22 -22
  22. package/dist/matching/matcher-definitions.js.map +1 -1
  23. package/dist/matching/matcher-impls.d.ts +27 -0
  24. package/dist/matching/{matchers.js → matcher-impls.js} +23 -23
  25. package/dist/matching/matcher-impls.js.map +1 -0
  26. package/dist/mockrtc-peer.d.ts +1 -0
  27. package/dist/mockrtc.d.ts +4 -3
  28. package/dist/rule-builder.d.ts +2 -1
  29. package/dist/rule-builder.js +7 -7
  30. package/dist/rule-builder.js.map +1 -1
  31. package/dist/server/mockrtc-admin-plugin.d.ts +1 -1
  32. package/dist/server/mockrtc-admin-plugin.js +12 -10
  33. package/dist/server/mockrtc-admin-plugin.js.map +1 -1
  34. package/dist/server/mockrtc-server-peer.d.ts +4 -2
  35. package/dist/server/mockrtc-server-peer.js +9 -10
  36. package/dist/server/mockrtc-server-peer.js.map +1 -1
  37. package/dist/server/mockrtc-server.js +6 -6
  38. package/dist/server/mockrtc-server.js.map +1 -1
  39. package/dist/webrtc/control-channel.d.ts +1 -1
  40. package/dist/webrtc/datachannel-stream.d.ts +6 -0
  41. package/dist/webrtc/datachannel-stream.js +4 -0
  42. package/dist/webrtc/datachannel-stream.js.map +1 -1
  43. package/dist/webrtc/mediatrack-stream.d.ts +7 -0
  44. package/dist/webrtc/mediatrack-stream.js +5 -0
  45. package/dist/webrtc/mediatrack-stream.js.map +1 -1
  46. package/dist/webrtc/mockrtc-connection.d.ts +1 -1
  47. package/dist/webrtc/mockrtc-connection.js +1 -0
  48. package/dist/webrtc/mockrtc-connection.js.map +1 -1
  49. package/dist/webrtc/rtc-connection.d.ts +4 -4
  50. package/dist/webrtc/rtc-connection.js +51 -36
  51. package/dist/webrtc/rtc-connection.js.map +1 -1
  52. package/package.json +10 -14
  53. package/src/handling/handler-builder.ts +24 -24
  54. package/src/handling/handler-step-definitions.ts +38 -22
  55. package/src/handling/{handler-steps.ts → handler-step-impls.ts} +36 -39
  56. package/src/main-browser.ts +2 -2
  57. package/src/main.ts +3 -3
  58. package/src/matching/matcher-definitions.ts +14 -14
  59. package/src/matching/{matchers.ts → matcher-impls.ts} +22 -22
  60. package/src/rule-builder.ts +14 -14
  61. package/src/server/mockrtc-admin-plugin.ts +15 -11
  62. package/src/server/mockrtc-server-peer.ts +12 -14
  63. package/src/server/mockrtc-server.ts +8 -8
  64. package/src/webrtc/datachannel-stream.ts +4 -0
  65. package/src/webrtc/mediatrack-stream.ts +5 -0
  66. package/src/webrtc/mockrtc-connection.ts +1 -0
  67. package/src/webrtc/rtc-connection.ts +9 -5
  68. package/test/tsconfig.json +2 -1
  69. package/tsconfig.json +3 -1
  70. package/dist/control-channel.d.ts +0 -8
  71. package/dist/control-channel.js +0 -11
  72. package/dist/control-channel.js.map +0 -1
  73. package/dist/handling/handler-steps.d.ts +0 -58
  74. package/dist/handling/handler-steps.js.map +0 -1
  75. package/dist/matching/matchers.d.ts +0 -27
  76. package/dist/matching/matchers.js.map +0 -1
  77. package/dist/mockrtc-admin-plugin.d.ts +0 -56
  78. package/dist/mockrtc-admin-plugin.js +0 -151
  79. package/dist/mockrtc-admin-plugin.js.map +0 -1
  80. package/dist/mockrtc-admin-server.d.ts +0 -7
  81. package/dist/mockrtc-admin-server.js +0 -18
  82. package/dist/mockrtc-admin-server.js.map +0 -1
  83. package/dist/mockrtc-client.d.ts +0 -12
  84. package/dist/mockrtc-client.js +0 -64
  85. package/dist/mockrtc-client.js.map +0 -1
  86. package/dist/mockrtc-handler-builder.d.ts +0 -15
  87. package/dist/mockrtc-handler-builder.js +0 -24
  88. package/dist/mockrtc-handler-builder.js.map +0 -1
  89. package/dist/mockrtc-remote-peer.d.ts +0 -15
  90. package/dist/mockrtc-remote-peer.js +0 -234
  91. package/dist/mockrtc-remote-peer.js.map +0 -1
  92. package/dist/mockrtc-server-peer.d.ts +0 -29
  93. package/dist/mockrtc-server-peer.js +0 -145
  94. package/dist/mockrtc-server-peer.js.map +0 -1
  95. package/dist/mockrtc-server.d.ts +0 -14
  96. package/dist/mockrtc-server.js +0 -53
  97. package/dist/mockrtc-server.js.map +0 -1
  98. package/dist/package.json +0 -52
  99. package/dist/src/main.d.ts +0 -1
  100. package/dist/src/main.js +0 -24
  101. package/dist/src/main.js.map +0 -1
  102. package/dist/src/mockrtc-peer.d.ts +0 -0
  103. package/dist/src/mockrtc-peer.js +0 -2
  104. package/dist/src/mockrtc-peer.js.map +0 -1
  105. package/dist/src/mockrtc.d.ts +0 -0
  106. package/dist/src/mockrtc.js +0 -65
  107. package/dist/src/mockrtc.js.map +0 -1
  108. package/dist/webrtc/peer-connection.d.ts +0 -16
  109. package/dist/webrtc/peer-connection.js +0 -81
  110. package/dist/webrtc/peer-connection.js.map +0 -1
@@ -6,6 +6,7 @@
6
6
  import * as PluggableAdmin from 'mockttp/dist/pluggable-admin-api/pluggable-admin.browser';
7
7
 
8
8
  import { MockRTCSessionDescription } from '../mockrtc';
9
+ import type { RTCConnection } from '../webrtc/rtc-connection';
9
10
 
10
11
  export type Serializable = PluggableAdmin.Serialization.Serializable;
11
12
  export const { Serializable } = PluggableAdmin.Serialization;
@@ -15,9 +16,10 @@ export interface HandlerStepDefinition extends Serializable {
15
16
  readonly type: keyof typeof StepDefinitionLookup;
16
17
  }
17
18
 
18
- export class WaitForDurationStepDefinition extends Serializable implements HandlerStepDefinition {
19
+ export class WaitForDurationStep extends Serializable implements HandlerStepDefinition {
19
20
 
20
21
  readonly type = 'wait-for-duration';
22
+ static readonly isFinal = false;
21
23
 
22
24
  constructor(
23
25
  public readonly durationMs: number
@@ -31,9 +33,10 @@ export class WaitForDurationStepDefinition extends Serializable implements Handl
31
33
 
32
34
  }
33
35
 
34
- export class WaitForChannelStepDefinition extends Serializable implements HandlerStepDefinition {
36
+ export class WaitForChannelStep extends Serializable implements HandlerStepDefinition {
35
37
 
36
38
  readonly type = 'wait-for-rtc-data-channel';
39
+ static readonly isFinal = false;
37
40
 
38
41
  constructor(
39
42
  public readonly channelLabel?: string
@@ -47,9 +50,10 @@ export class WaitForChannelStepDefinition extends Serializable implements Handle
47
50
 
48
51
  }
49
52
 
50
- export class WaitForMessageStepDefinition extends Serializable implements HandlerStepDefinition {
53
+ export class WaitForMessageStep extends Serializable implements HandlerStepDefinition {
51
54
 
52
55
  readonly type = 'wait-for-rtc-message';
56
+ static readonly isFinal = false;
53
57
 
54
58
  constructor(
55
59
  public readonly channelLabel?: string
@@ -63,9 +67,10 @@ export class WaitForMessageStepDefinition extends Serializable implements Handle
63
67
 
64
68
  }
65
69
 
66
- export class WaitForTrackStepDefinition extends Serializable implements HandlerStepDefinition {
70
+ export class WaitForTrackStep extends Serializable implements HandlerStepDefinition {
67
71
 
68
72
  readonly type = 'wait-for-rtc-track';
73
+ static readonly isFinal = false;
69
74
 
70
75
  explain() {
71
76
  return `wait for an RTC track`;
@@ -73,9 +78,10 @@ export class WaitForTrackStepDefinition extends Serializable implements HandlerS
73
78
 
74
79
  }
75
80
 
76
- export class WaitForMediaStepDefinition extends Serializable implements HandlerStepDefinition {
81
+ export class WaitForMediaStep extends Serializable implements HandlerStepDefinition {
77
82
 
78
83
  readonly type = 'wait-for-rtc-media';
84
+ static readonly isFinal = false;
79
85
 
80
86
  explain() {
81
87
  return `wait for RTC media data`;
@@ -83,9 +89,10 @@ export class WaitForMediaStepDefinition extends Serializable implements HandlerS
83
89
 
84
90
  }
85
91
 
86
- export class CreateChannelStepDefinition extends Serializable implements HandlerStepDefinition {
92
+ export class CreateChannelStep extends Serializable implements HandlerStepDefinition {
87
93
 
88
94
  readonly type = 'create-rtc-data-channel';
95
+ static readonly isFinal = false;
89
96
 
90
97
  constructor(
91
98
  public readonly channelLabel: string
@@ -99,9 +106,10 @@ export class CreateChannelStepDefinition extends Serializable implements Handler
99
106
 
100
107
  }
101
108
 
102
- export class SendStepDefinition extends Serializable implements HandlerStepDefinition {
109
+ export class SendStep extends Serializable implements HandlerStepDefinition {
103
110
 
104
111
  readonly type = 'send-rtc-data-message';
112
+ static readonly isFinal = false;
105
113
 
106
114
  constructor(
107
115
  public readonly channelLabel: string | undefined,
@@ -116,9 +124,10 @@ export class SendStepDefinition extends Serializable implements HandlerStepDefin
116
124
 
117
125
  }
118
126
 
119
- export class CloseStepDefinition extends Serializable implements HandlerStepDefinition {
127
+ export class CloseStep extends Serializable implements HandlerStepDefinition {
120
128
 
121
129
  readonly type = 'close-rtc-connection';
130
+ static readonly isFinal = true;
122
131
 
123
132
  explain() {
124
133
  return `close the RTC connection`;
@@ -126,9 +135,10 @@ export class CloseStepDefinition extends Serializable implements HandlerStepDefi
126
135
 
127
136
  }
128
137
 
129
- export class EchoStepDefinition extends Serializable implements HandlerStepDefinition {
138
+ export class EchoStep extends Serializable implements HandlerStepDefinition {
130
139
 
131
140
  readonly type = 'echo-rtc';
141
+ static readonly isFinal = true;
132
142
 
133
143
  explain() {
134
144
  return `echo all RTC media & data`;
@@ -136,9 +146,12 @@ export class EchoStepDefinition extends Serializable implements HandlerStepDefin
136
146
 
137
147
  }
138
148
 
139
- export class PeerProxyStepDefinition extends Serializable implements HandlerStepDefinition {
149
+ export class PeerProxyStep extends Serializable implements HandlerStepDefinition {
140
150
 
141
151
  readonly type = 'rtc-peer-proxy';
152
+ static readonly isFinal = true;
153
+
154
+ protected externalConnections: RTCConnection[] = []; // Set here so it can be used in impl subclass
142
155
 
143
156
  protected getAnswer: (offer: MockRTCSessionDescription) => Promise<RTCSessionDescriptionInit>;
144
157
 
@@ -177,9 +190,12 @@ export class PeerProxyStepDefinition extends Serializable implements HandlerStep
177
190
 
178
191
  }
179
192
 
180
- export class DynamicProxyStepDefinition extends Serializable implements HandlerStepDefinition {
193
+ export class DynamicProxyStep extends Serializable implements HandlerStepDefinition {
181
194
 
182
195
  readonly type = 'rtc-dynamic-proxy';
196
+ static readonly isFinal = true;
197
+
198
+ protected externalConnections: RTCConnection[] = []; // Set here so it can be used in impl subclass
183
199
 
184
200
  explain() {
185
201
  return `proxy the RTC connection to a remote peer`;
@@ -188,15 +204,15 @@ export class DynamicProxyStepDefinition extends Serializable implements HandlerS
188
204
  }
189
205
 
190
206
  export const StepDefinitionLookup = {
191
- 'wait-for-duration': WaitForDurationStepDefinition,
192
- 'wait-for-rtc-data-channel': WaitForChannelStepDefinition,
193
- 'wait-for-rtc-track': WaitForTrackStepDefinition,
194
- 'wait-for-rtc-media': WaitForMediaStepDefinition,
195
- 'wait-for-rtc-message': WaitForMessageStepDefinition,
196
- 'create-rtc-data-channel': CreateChannelStepDefinition,
197
- 'send-rtc-data-message': SendStepDefinition,
198
- 'close-rtc-connection': CloseStepDefinition,
199
- 'echo-rtc': EchoStepDefinition,
200
- 'rtc-peer-proxy': PeerProxyStepDefinition,
201
- 'rtc-dynamic-proxy': DynamicProxyStepDefinition
207
+ 'wait-for-duration': WaitForDurationStep,
208
+ 'wait-for-rtc-data-channel': WaitForChannelStep,
209
+ 'wait-for-rtc-track': WaitForTrackStep,
210
+ 'wait-for-rtc-media': WaitForMediaStep,
211
+ 'wait-for-rtc-message': WaitForMessageStep,
212
+ 'create-rtc-data-channel': CreateChannelStep,
213
+ 'send-rtc-data-message': SendStep,
214
+ 'close-rtc-connection': CloseStep,
215
+ 'echo-rtc': EchoStep,
216
+ 'rtc-peer-proxy': PeerProxyStep,
217
+ 'rtc-dynamic-proxy': DynamicProxyStep
202
218
  };
@@ -12,27 +12,27 @@ import type { MockRTCConnection } from '../webrtc/mockrtc-connection';
12
12
  import { RTCConnection } from '../webrtc/rtc-connection';
13
13
  import {
14
14
  StepDefinitionLookup,
15
- CloseStepDefinition,
16
- DynamicProxyStepDefinition,
17
- EchoStepDefinition,
15
+ CloseStep,
16
+ DynamicProxyStep,
17
+ EchoStep,
18
18
  HandlerStepDefinition,
19
- PeerProxyStepDefinition,
20
- CreateChannelStepDefinition,
21
- SendStepDefinition,
22
- WaitForChannelStepDefinition,
23
- WaitForDurationStepDefinition,
24
- WaitForMediaStepDefinition,
25
- WaitForMessageStepDefinition,
26
- WaitForTrackStepDefinition
19
+ PeerProxyStep,
20
+ CreateChannelStep,
21
+ SendStep,
22
+ WaitForChannelStep,
23
+ WaitForDurationStep,
24
+ WaitForMediaStep,
25
+ WaitForMessageStep,
26
+ WaitForTrackStep
27
27
  } from './handler-step-definitions';
28
28
 
29
29
  type ClientServerChannel = PluggableAdmin.Serialization.ClientServerChannel;
30
30
 
31
- export interface HandlerStep extends HandlerStepDefinition {
31
+ export interface HandlerStepImpl extends HandlerStepDefinition {
32
32
  handle(connection: MockRTCConnection): Promise<void>;
33
33
  }
34
34
 
35
- export class WaitForDurationStep extends WaitForDurationStepDefinition {
35
+ export class WaitForDurationStepImpl extends WaitForDurationStep {
36
36
 
37
37
  async handle(): Promise<void> {
38
38
  return new Promise<void>((resolve) => setTimeout(resolve, this.durationMs));
@@ -40,7 +40,7 @@ export class WaitForDurationStep extends WaitForDurationStepDefinition {
40
40
 
41
41
  }
42
42
 
43
- export class WaitForChannelStep extends WaitForChannelStepDefinition {
43
+ export class WaitForChannelStepImpl extends WaitForChannelStep {
44
44
 
45
45
  private matchesChannel(channel: DataChannelStream) {
46
46
  return this.channelLabel === undefined || this.channelLabel === channel.label;
@@ -62,7 +62,7 @@ export class WaitForChannelStep extends WaitForChannelStepDefinition {
62
62
 
63
63
  }
64
64
 
65
- export class WaitForMessageStep extends WaitForMessageStepDefinition {
65
+ export class WaitForMessageStepImpl extends WaitForMessageStep {
66
66
 
67
67
  private matchesChannel(channel: DataChannelStream) {
68
68
  return this.channelLabel === undefined || this.channelLabel === channel.label;
@@ -93,7 +93,7 @@ export class WaitForMessageStep extends WaitForMessageStepDefinition {
93
93
 
94
94
  }
95
95
 
96
- export class WaitForTrackStep extends WaitForTrackStepDefinition {
96
+ export class WaitForTrackStepImpl extends WaitForTrackStep {
97
97
 
98
98
  async handle(connection: MockRTCConnection): Promise<void> {
99
99
  await new Promise<void>((resolve) => {
@@ -104,7 +104,7 @@ export class WaitForTrackStep extends WaitForTrackStepDefinition {
104
104
 
105
105
  }
106
106
 
107
- export class WaitForMediaStep extends WaitForMediaStepDefinition {
107
+ export class WaitForMediaStepImpl extends WaitForMediaStep {
108
108
 
109
109
  async handle(connection: MockRTCConnection): Promise<void> {
110
110
  return new Promise<void>((resolve) => {
@@ -129,7 +129,7 @@ export class WaitForMediaStep extends WaitForMediaStepDefinition {
129
129
 
130
130
  }
131
131
 
132
- export class CreateChannelStep extends CreateChannelStepDefinition {
132
+ export class CreateChannelStepImpl extends CreateChannelStep {
133
133
 
134
134
  async handle(conn: MockRTCConnection): Promise<void> {
135
135
  const channel = conn.createDataChannel(this.channelLabel);
@@ -140,7 +140,7 @@ export class CreateChannelStep extends CreateChannelStepDefinition {
140
140
 
141
141
  }
142
142
 
143
- export class SendStep extends SendStepDefinition {
143
+ export class SendStepImpl extends SendStep {
144
144
 
145
145
  private matchesChannel(channel: DataChannelStream) {
146
146
  return this.channelLabel === undefined || this.channelLabel === channel.label;
@@ -177,7 +177,7 @@ export class SendStep extends SendStepDefinition {
177
177
 
178
178
  }
179
179
 
180
- export class CloseStep extends CloseStepDefinition {
180
+ export class CloseStepImpl extends CloseStep {
181
181
 
182
182
  async handle(connection: MockRTCConnection): Promise<void> {
183
183
  await connection.close();
@@ -185,7 +185,7 @@ export class CloseStep extends CloseStepDefinition {
185
185
 
186
186
  }
187
187
 
188
- export class EchoStep extends EchoStepDefinition {
188
+ export class EchoStepImpl extends EchoStep {
189
189
 
190
190
  async handle(connection: MockRTCConnection): Promise<void> {
191
191
  const echoContent = (stream: DataChannelStream | MediaTrackStream) => {
@@ -203,9 +203,7 @@ export class EchoStep extends EchoStepDefinition {
203
203
 
204
204
  }
205
205
 
206
- export class PeerProxyStep extends PeerProxyStepDefinition {
207
-
208
- private externalConnections: RTCConnection[] = [];
206
+ export class PeerProxyStepImpl extends PeerProxyStep {
209
207
 
210
208
  async handle(connection: MockRTCConnection) {
211
209
  const externalConn = new RTCConnection();
@@ -250,12 +248,11 @@ export class PeerProxyStep extends PeerProxyStepDefinition {
250
248
 
251
249
  }
252
250
 
253
- export class DynamicProxyStep extends DynamicProxyStepDefinition {
254
-
255
- private externalConnections: RTCConnection[] = [];
251
+ export class DynamicProxyStepImpl extends DynamicProxyStep {
256
252
 
257
253
  async handle(connection: MockRTCConnection) {
258
- await connection.proxyTrafficToExternalConnection();
254
+ const externalConn = await connection.proxyTrafficToExternalConnection();
255
+ this.externalConnections.push(externalConn);
259
256
 
260
257
  // This step keeps running indefinitely, until the connection closes
261
258
  return new Promise<void>((resolve) => connection.on('connection-closed', resolve));
@@ -268,15 +265,15 @@ export class DynamicProxyStep extends DynamicProxyStepDefinition {
268
265
  }
269
266
 
270
267
  export const StepLookup: typeof StepDefinitionLookup = {
271
- 'wait-for-duration': WaitForDurationStep,
272
- 'wait-for-rtc-data-channel': WaitForChannelStep,
273
- 'wait-for-rtc-track': WaitForTrackStep,
274
- 'wait-for-rtc-media': WaitForMediaStep,
275
- 'wait-for-rtc-message': WaitForMessageStep,
276
- 'create-rtc-data-channel': CreateChannelStep,
277
- 'send-rtc-data-message': SendStep,
278
- 'close-rtc-connection': CloseStep,
279
- 'echo-rtc': EchoStep,
280
- 'rtc-peer-proxy': PeerProxyStep,
281
- 'rtc-dynamic-proxy': DynamicProxyStep
268
+ 'wait-for-duration': WaitForDurationStepImpl,
269
+ 'wait-for-rtc-data-channel': WaitForChannelStepImpl,
270
+ 'wait-for-rtc-track': WaitForTrackStepImpl,
271
+ 'wait-for-rtc-media': WaitForMediaStepImpl,
272
+ 'wait-for-rtc-message': WaitForMessageStepImpl,
273
+ 'create-rtc-data-channel': CreateChannelStepImpl,
274
+ 'send-rtc-data-message': SendStepImpl,
275
+ 'close-rtc-connection': CloseStepImpl,
276
+ 'echo-rtc': EchoStepImpl,
277
+ 'rtc-peer-proxy': PeerProxyStepImpl,
278
+ 'rtc-dynamic-proxy': DynamicProxyStepImpl
282
279
  };
@@ -10,8 +10,8 @@ import type {
10
10
  import { MockRTCClient, MockRTCClientOptions } from "./client/mockrtc-client";
11
11
 
12
12
  // Export the required structures to remotely build and send rules to the admin API:
13
- export * as HandlerStepDefinitions from "./handling/handler-step-definitions";
14
- export * as MatcherDefinitions from "./matching/matcher-definitions";
13
+ export * as steps from "./handling/handler-step-definitions";
14
+ export * as matchers from "./matching/matcher-definitions";
15
15
  export { MockRTCAdminRequestBuilder } from "./client/mockrtc-admin-request-builder";
16
16
 
17
17
  export type {
package/src/main.ts CHANGED
@@ -22,12 +22,12 @@ export { MockRTCAdminPlugin } from "./server/mockrtc-admin-plugin";
22
22
  import { MockRTCClient, MockRTCClientOptions } from "./client/mockrtc-client";
23
23
 
24
24
  // Export the required structures to remotely build and send rules to the admin API:
25
- export * as HandlerStepDefinitions from "./handling/handler-step-definitions";
26
- export * as MatcherDefinitions from "./matching/matcher-definitions";
25
+ export * as steps from "./handling/handler-step-definitions";
26
+ export * as matchers from "./matching/matcher-definitions";
27
27
  export { MockRTCAdminRequestBuilder } from "./client/mockrtc-admin-request-builder";
28
28
 
29
29
  // Re-export lots of types are used in various APIs (mostly to make TypeDoc happy):
30
- export type { HandlerStep } from "./handling/handler-steps";
30
+ export type { HandlerStepImpl as HandlerStep } from "./handling/handler-step-impls";
31
31
  export type { MockRTCHandlerBuilder } from "./handling/handler-builder";
32
32
  export type { MockRTCRuleBuilder, RuleHandlerBuilder } from "./rule-builder";
33
33
 
@@ -12,7 +12,7 @@ export interface MatcherDefinition extends Serializable {
12
12
  readonly type: keyof typeof MatcherDefinitionLookup;
13
13
  }
14
14
 
15
- export class HasDataChannelMatcherDefinition extends Serializable implements MatcherDefinition {
15
+ export class HasDataChannelMatcher extends Serializable implements MatcherDefinition {
16
16
  readonly type = 'has-rtc-data-channel';
17
17
 
18
18
  explain() {
@@ -20,7 +20,7 @@ export class HasDataChannelMatcherDefinition extends Serializable implements Mat
20
20
  }
21
21
  }
22
22
 
23
- export class HasVideoTrackMatcherDefinition extends Serializable implements MatcherDefinition {
23
+ export class HasVideoTrackMatcher extends Serializable implements MatcherDefinition {
24
24
  readonly type = 'has-rtc-video-track';
25
25
 
26
26
  explain() {
@@ -28,7 +28,7 @@ export class HasVideoTrackMatcherDefinition extends Serializable implements Matc
28
28
  }
29
29
  }
30
30
 
31
- export class HasAudioTrackMatcherDefinition extends Serializable implements MatcherDefinition {
31
+ export class HasAudioTrackMatcher extends Serializable implements MatcherDefinition {
32
32
  readonly type = 'has-rtc-audio-track';
33
33
 
34
34
  explain() {
@@ -36,7 +36,7 @@ export class HasAudioTrackMatcherDefinition extends Serializable implements Matc
36
36
  }
37
37
  }
38
38
 
39
- export class HasMediaTrackMatcherDefinition extends Serializable implements MatcherDefinition {
39
+ export class HasMediaTrackMatcher extends Serializable implements MatcherDefinition {
40
40
  readonly type = 'has-rtc-media-track';
41
41
 
42
42
  explain() {
@@ -44,7 +44,7 @@ export class HasMediaTrackMatcherDefinition extends Serializable implements Matc
44
44
  }
45
45
  }
46
46
 
47
- export class HostnameMatcherDefinition extends Serializable implements MatcherDefinition {
47
+ export class HostnameMatcher extends Serializable implements MatcherDefinition {
48
48
 
49
49
  readonly type = 'rtc-page-hostname';
50
50
 
@@ -60,7 +60,7 @@ export class HostnameMatcherDefinition extends Serializable implements MatcherDe
60
60
 
61
61
  }
62
62
 
63
- export class UrlRegexMatcherDefinition extends Serializable implements MatcherDefinition {
63
+ export class UrlRegexMatcher extends Serializable implements MatcherDefinition {
64
64
 
65
65
  readonly type = 'rtc-page-regex';
66
66
 
@@ -79,7 +79,7 @@ export class UrlRegexMatcherDefinition extends Serializable implements MatcherDe
79
79
 
80
80
  }
81
81
 
82
- export class UserAgentRegexMatcherDefinition extends Serializable implements MatcherDefinition {
82
+ export class UserAgentRegexMatcher extends Serializable implements MatcherDefinition {
83
83
 
84
84
  readonly type = 'rtc-user-agent-regex';
85
85
 
@@ -99,11 +99,11 @@ export class UserAgentRegexMatcherDefinition extends Serializable implements Ma
99
99
  }
100
100
 
101
101
  export const MatcherDefinitionLookup = {
102
- 'has-rtc-data-channel': HasDataChannelMatcherDefinition,
103
- 'has-rtc-video-track': HasVideoTrackMatcherDefinition,
104
- 'has-rtc-audio-track': HasAudioTrackMatcherDefinition,
105
- 'has-rtc-media-track': HasMediaTrackMatcherDefinition,
106
- 'rtc-page-hostname': HostnameMatcherDefinition,
107
- 'rtc-page-regex': UrlRegexMatcherDefinition,
108
- 'rtc-user-agent-regex': UserAgentRegexMatcherDefinition
102
+ 'has-rtc-data-channel': HasDataChannelMatcher,
103
+ 'has-rtc-video-track': HasVideoTrackMatcher,
104
+ 'has-rtc-audio-track': HasAudioTrackMatcher,
105
+ 'has-rtc-media-track': HasMediaTrackMatcher,
106
+ 'rtc-page-hostname': HostnameMatcher,
107
+ 'rtc-page-regex': UrlRegexMatcher,
108
+ 'rtc-user-agent-regex': UserAgentRegexMatcher
109
109
  };
@@ -7,20 +7,20 @@ import { RTCConnection } from "../webrtc/rtc-connection";
7
7
  import {
8
8
  MatcherDefinition,
9
9
  MatcherDefinitionLookup,
10
- HasAudioTrackMatcherDefinition,
11
- HasDataChannelMatcherDefinition,
12
- HasMediaTrackMatcherDefinition,
13
- HasVideoTrackMatcherDefinition,
14
- HostnameMatcherDefinition,
15
- UrlRegexMatcherDefinition,
16
- UserAgentRegexMatcherDefinition
10
+ HasAudioTrackMatcher,
11
+ HasDataChannelMatcher,
12
+ HasMediaTrackMatcher,
13
+ HasVideoTrackMatcher,
14
+ HostnameMatcher,
15
+ UrlRegexMatcher,
16
+ UserAgentRegexMatcher
17
17
  } from "./matcher-definitions";
18
18
 
19
- export interface Matcher extends MatcherDefinition {
19
+ export interface MatcherImpl extends MatcherDefinition {
20
20
  matches(connection: RTCConnection): boolean;
21
21
  }
22
22
 
23
- export class HasDataChannelMatcher extends HasDataChannelMatcherDefinition {
23
+ export class HasDataChannelMatcherImpl extends HasDataChannelMatcher {
24
24
 
25
25
  matches(connection: RTCConnection): boolean {
26
26
  return [
@@ -31,7 +31,7 @@ export class HasDataChannelMatcher extends HasDataChannelMatcherDefinition {
31
31
 
32
32
  }
33
33
 
34
- export class HasVideoTrackMatcher extends HasVideoTrackMatcherDefinition {
34
+ export class HasVideoTrackMatcherImpl extends HasVideoTrackMatcher {
35
35
 
36
36
  matches(connection: RTCConnection): boolean {
37
37
  return [
@@ -42,7 +42,7 @@ export class HasVideoTrackMatcher extends HasVideoTrackMatcherDefinition {
42
42
 
43
43
  }
44
44
 
45
- export class HasAudioTrackMatcher extends HasAudioTrackMatcherDefinition {
45
+ export class HasAudioTrackMatcherImpl extends HasAudioTrackMatcher {
46
46
 
47
47
  matches(connection: RTCConnection): boolean {
48
48
  return [
@@ -53,7 +53,7 @@ export class HasAudioTrackMatcher extends HasAudioTrackMatcherDefinition {
53
53
 
54
54
  }
55
55
 
56
- export class HasMediaTrackMatcher extends HasMediaTrackMatcherDefinition {
56
+ export class HasMediaTrackMatcherImpl extends HasMediaTrackMatcher {
57
57
 
58
58
  matches(connection: RTCConnection): boolean {
59
59
  return [
@@ -76,7 +76,7 @@ const getConnectionSourceURL = (connection: RTCConnection): URL | undefined => {
76
76
  }
77
77
  };
78
78
 
79
- export class HostnameMatcher extends HostnameMatcherDefinition {
79
+ export class HostnameMatcherImpl extends HostnameMatcher {
80
80
 
81
81
  matches(connection: RTCConnection): boolean {
82
82
  const url = getConnectionSourceURL(connection);
@@ -85,7 +85,7 @@ export class HostnameMatcher extends HostnameMatcherDefinition {
85
85
 
86
86
  }
87
87
 
88
- export class UrlRegexMatcher extends UrlRegexMatcherDefinition {
88
+ export class UrlRegexMatcherImpl extends UrlRegexMatcher {
89
89
 
90
90
  matches(connection: RTCConnection): boolean {
91
91
  const url = getConnectionSourceURL(connection);
@@ -96,7 +96,7 @@ export class UrlRegexMatcher extends UrlRegexMatcherDefinition {
96
96
 
97
97
  }
98
98
 
99
- export class UserAgentRegexMatcher extends UserAgentRegexMatcherDefinition {
99
+ export class UserAgentRegexMatcherImpl extends UserAgentRegexMatcher {
100
100
 
101
101
  matches(connection: RTCConnection): boolean {
102
102
  const userAgent = connection.metadata.userAgent;
@@ -108,11 +108,11 @@ export class UserAgentRegexMatcher extends UserAgentRegexMatcherDefinition {
108
108
  }
109
109
 
110
110
  export const MatcherLookup: typeof MatcherDefinitionLookup = {
111
- 'has-rtc-data-channel': HasDataChannelMatcher,
112
- 'has-rtc-video-track': HasVideoTrackMatcher,
113
- 'has-rtc-audio-track': HasAudioTrackMatcher,
114
- 'has-rtc-media-track': HasMediaTrackMatcher,
115
- 'rtc-page-hostname': HostnameMatcher,
116
- 'rtc-page-regex': UrlRegexMatcher,
117
- 'rtc-user-agent-regex': UserAgentRegexMatcher
111
+ 'has-rtc-data-channel': HasDataChannelMatcherImpl,
112
+ 'has-rtc-video-track': HasVideoTrackMatcherImpl,
113
+ 'has-rtc-audio-track': HasAudioTrackMatcherImpl,
114
+ 'has-rtc-media-track': HasMediaTrackMatcherImpl,
115
+ 'rtc-page-hostname': HostnameMatcherImpl,
116
+ 'rtc-page-regex': UrlRegexMatcherImpl,
117
+ 'rtc-user-agent-regex': UserAgentRegexMatcherImpl
118
118
  };
@@ -7,13 +7,13 @@ import { MockRTCHandlerBuilder } from "./handling/handler-builder";
7
7
  import { HandlerStepDefinition } from "./handling/handler-step-definitions";
8
8
  import {
9
9
  MatcherDefinition,
10
- HostnameMatcherDefinition,
11
- UrlRegexMatcherDefinition,
12
- UserAgentRegexMatcherDefinition,
13
- HasAudioTrackMatcherDefinition,
14
- HasVideoTrackMatcherDefinition,
15
- HasMediaTrackMatcherDefinition,
16
- HasDataChannelMatcherDefinition
10
+ HostnameMatcher,
11
+ UrlRegexMatcher,
12
+ UserAgentRegexMatcher,
13
+ HasAudioTrackMatcher,
14
+ HasVideoTrackMatcher,
15
+ HasMediaTrackMatcher,
16
+ HasDataChannelMatcher
17
17
  } from "./matching/matcher-definitions";
18
18
 
19
19
  export type RuleHandlerBuilder = MockRTCHandlerBuilder<void>;
@@ -38,7 +38,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
38
38
  * Match RTC connections whose initial negotiation includes a data channel.
39
39
  */
40
40
  withDataChannels() {
41
- this.matchers.push(new HasDataChannelMatcherDefinition());
41
+ this.matchers.push(new HasDataChannelMatcher());
42
42
  return this;
43
43
  }
44
44
 
@@ -47,7 +47,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
47
47
  * media track.
48
48
  */
49
49
  withMedia() {
50
- this.matchers.push(new HasMediaTrackMatcherDefinition());
50
+ this.matchers.push(new HasMediaTrackMatcher());
51
51
  return this;
52
52
  }
53
53
 
@@ -55,7 +55,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
55
55
  * Match RTC connections whose initial negotiation includes a video media track
56
56
  */
57
57
  withVideo() {
58
- this.matchers.push(new HasVideoTrackMatcherDefinition());
58
+ this.matchers.push(new HasVideoTrackMatcher());
59
59
  return this;
60
60
  }
61
61
 
@@ -63,7 +63,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
63
63
  * Match RTC connections whose initial negotiation includes an audio media track
64
64
  */
65
65
  withAudio() {
66
- this.matchers.push(new HasAudioTrackMatcherDefinition());
66
+ this.matchers.push(new HasAudioTrackMatcher());
67
67
  return this;
68
68
  }
69
69
 
@@ -78,7 +78,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
78
78
  * @category Matcher
79
79
  */
80
80
  fromPageHostname(hostname: string): this {
81
- this.matchers.push(new HostnameMatcherDefinition(hostname));
81
+ this.matchers.push(new HostnameMatcher(hostname));
82
82
  return this;
83
83
  }
84
84
 
@@ -93,7 +93,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
93
93
  * @category Matcher
94
94
  */
95
95
  fromPageUrlMatching(urlRegex: RegExp): this {
96
- this.matchers.push(new UrlRegexMatcherDefinition(urlRegex));
96
+ this.matchers.push(new UrlRegexMatcher(urlRegex));
97
97
  return this;
98
98
  }
99
99
 
@@ -109,7 +109,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
109
109
  * @category Matcher
110
110
  */
111
111
  fromUserAgentMatching(userAgentRegEx: RegExp): this {
112
- this.matchers.push(new UserAgentRegexMatcherDefinition(userAgentRegEx));
112
+ this.matchers.push(new UserAgentRegexMatcher(userAgentRegEx));
113
113
  return this;
114
114
  }
115
115