@league-of-foundry-developers/foundry-vtt-types 9.255.0 → 9.255.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 (43) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/foundry/common/types.mjs.d.ts +120 -8
  4. package/src/foundry/common/utils/http.mjs.d.ts +52 -0
  5. package/src/foundry/common/utils/module.mjs.d.ts +1 -0
  6. package/src/foundry/common/utils/semaphore.mjs.d.ts +6 -3
  7. package/src/foundry/foundry.js/applications/formApplications/documentSheets/actorSheet.d.ts +8 -6
  8. package/src/foundry/foundry.js/applications/formApplications/settingsConfig.d.ts +4 -4
  9. package/src/foundry/foundry.js/avClient.d.ts +15 -1
  10. package/src/foundry/foundry.js/avClients/index.d.ts +0 -1
  11. package/src/foundry/foundry.js/avClients/simplePeerAVClient.d.ts +31 -4
  12. package/src/foundry/foundry.js/avMaster.d.ts +21 -48
  13. package/src/foundry/foundry.js/avSettings.d.ts +19 -46
  14. package/src/foundry/foundry.js/clientDocumentMixin.d.ts +2 -2
  15. package/src/foundry/foundry.js/clientDocuments/activeEffect.d.ts +28 -6
  16. package/src/foundry/foundry.js/clientDocuments/actor.d.ts +13 -70
  17. package/src/foundry/foundry.js/clientDocuments/canvasDocuments/tokenDocument.d.ts +42 -9
  18. package/src/foundry/foundry.js/clientDocuments/folder.d.ts +22 -20
  19. package/src/foundry/foundry.js/clientDocuments/item.d.ts +5 -23
  20. package/src/foundry/foundry.js/clientDocuments/macro.d.ts +10 -0
  21. package/src/foundry/foundry.js/clientDocuments/playlistSound.d.ts +1 -1
  22. package/src/foundry/foundry.js/clientDocuments/prototypeToken.d.ts +24 -14
  23. package/src/foundry/foundry.js/clientDocuments/rollTable.d.ts +16 -14
  24. package/src/foundry/foundry.js/clientDocuments/scene.d.ts +12 -7
  25. package/src/foundry/foundry.js/clientDocuments/user.d.ts +2 -12
  26. package/src/foundry/foundry.js/clientSettings.d.ts +38 -86
  27. package/src/foundry/foundry.js/gamepadManager.d.ts +12 -0
  28. package/src/foundry/foundry.js/globalVariables.d.ts +0 -31
  29. package/src/foundry/foundry.js/pixi/containers/baseGrid.d.ts +21 -6
  30. package/src/foundry/foundry.js/pixi/containers/baseGrids/hexagonalGrid.d.ts +13 -8
  31. package/src/foundry/foundry.js/pixi/containers/baseGrids/squareGrid.d.ts +5 -3
  32. package/src/foundry/foundry.js/pixi/containers/canvasLayers/gridLayer.d.ts +14 -5
  33. package/src/foundry/foundry.js/pixi/containers/placeableObject.d.ts +9 -55
  34. package/src/foundry/foundry.js/pixi/containers/placeableObjects/ambientSound.d.ts +3 -0
  35. package/src/foundry/foundry.js/pixi/containers/placeableObjects/drawing.d.ts +3 -0
  36. package/src/foundry/foundry.js/pixi/containers/placeableObjects/measuredTemplate.d.ts +3 -0
  37. package/src/foundry/foundry.js/pixi/containers/placeableObjects/note.d.ts +3 -0
  38. package/src/foundry/foundry.js/pixi/containers/placeableObjects/tile.d.ts +3 -0
  39. package/src/foundry/foundry.js/pixi/containers/placeableObjects/token.d.ts +3 -0
  40. package/src/foundry/index.d.ts +0 -4
  41. package/src/foundry/foundry.js/avClients/easyRTCClient.d.ts +0 -392
  42. package/src/foundry/foundry.js/features.d.ts +0 -0
  43. package/src/foundry/foundry.js/fonts.d.ts +0 -24
package/README.md CHANGED
@@ -17,7 +17,7 @@ TypeScript type definitions for [Foundry Virtual Tabletop](https://foundryvtt.co
17
17
 
18
18
  We aim to support the latest release of each Foundry VTT version (0.7, 0.8, 9, etc.), starting with 0.7.
19
19
 
20
- At the moment, both version 0.7 and 0.8 are fully supported. Version 9 is already partially supported, but there is still a lot to be done. See https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues?q=is%3Aopen+is%3Aissue+label%3A%22foundry+V9%22 to keep track of the progress.
20
+ At the moment, both version 0.7 and 0.8 are fully supported. Version 9 is already partially supported, but there is still a lot to be done. See the [open foundry V9 issues](https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues?q=is%3Aopen+is%3Aissue+label%3A%22foundry+V9%22) to keep track of the progress.
21
21
 
22
22
 
23
23
  ## Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@league-of-foundry-developers/foundry-vtt-types",
3
- "version": "9.255.0",
3
+ "version": "9.255.1",
4
4
  "description": "TypeScript type definitions for Foundry VTT",
5
5
  "exports": {
6
6
  ".": {
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * A single point, expressed as an object \{x, y\}
3
3
  */
4
- declare type Point = PIXI.Point | { x: number; y: number };
4
+ type Point = PIXI.Point | { x: number; y: number };
5
5
 
6
6
  /**
7
7
  * A single point, expressed as an array \[x,y\]
8
8
  */
9
- declare type PointArray = [x: number, y: number];
9
+ type PointArray = [x: number, y: number];
10
10
 
11
11
  /**
12
12
  * A standard rectangle interface.
13
13
  */
14
- declare type Rectangle =
14
+ type Rectangle =
15
15
  | PIXI.Rectangle
16
16
  | {
17
17
  x: number;
@@ -20,8 +20,89 @@ declare type Rectangle =
20
20
  height: number;
21
21
  };
22
22
 
23
+ /** A Client Setting */
24
+ interface SettingConfig<T = unknown> {
25
+ /** A unique machine-readable id for the setting */
26
+ key: string;
27
+
28
+ /** The namespace the setting belongs to */
29
+ namespace: string;
30
+
31
+ /** The human readable name */
32
+ name?: string | undefined;
33
+
34
+ /** An additional human readable hint */
35
+ hint?: string | undefined;
36
+
37
+ /**
38
+ * The scope the Setting is stored in, either World or Client
39
+ * @defaultValue `'client'`
40
+ */
41
+ scope: 'world' | 'client';
42
+
43
+ /** Indicates if this Setting should render in the Config application */
44
+ config?: boolean | undefined;
45
+
46
+ /** The JS Type that the Setting is storing */
47
+ type?: T extends string
48
+ ? typeof String
49
+ : T extends number
50
+ ? typeof Number
51
+ : T extends boolean
52
+ ? typeof Boolean
53
+ : T extends Array<any>
54
+ ? typeof Array
55
+ : ConstructorOf<T>;
56
+
57
+ /** For string Types, defines the allowable values */
58
+ choices?: (T extends string ? Record<string, string> : never) | undefined;
59
+
60
+ /** For numeric Types, defines the allowable range */
61
+ range?:
62
+ | (T extends number
63
+ ? {
64
+ max: number;
65
+ min: number;
66
+ step: number;
67
+ }
68
+ : never)
69
+ | undefined;
70
+
71
+ /** The default value */
72
+ default?: T;
73
+
74
+ /** Executes when the value of this Setting changes */
75
+ onChange?: (value: T) => void;
76
+
77
+ filePicker?: (T extends string ? true | 'audio' | 'image' | 'video' | 'imagevideo' | 'folder' : never) | undefined;
78
+ }
79
+
80
+ interface SettingSubmenuConfig {
81
+ key: string;
82
+
83
+ namespace: string;
84
+
85
+ /** The human readable name */
86
+ name?: string | undefined;
87
+
88
+ /** The human readable label */
89
+ label?: string | undefined;
90
+
91
+ /** An additional human readable hint */
92
+ hint?: string | undefined;
93
+
94
+ /** The classname of an Icon to render */
95
+ icon?: string | undefined;
96
+
97
+ /** The FormApplication to render */
98
+ type: ConstructorOf<FormApplication<FormApplicationOptions, object, undefined>>;
99
+
100
+ /** If true, only a GM can edit this Setting */
101
+ restricted?: boolean | undefined;
102
+ }
103
+
23
104
  /** A Client Keybinding Action Configuration */
24
- declare interface KeybindingActionConfig {
105
+ interface KeybindingActionConfig {
25
106
  /** The namespace within which the action was registered */
26
107
  namespace?: string;
27
108
 
@@ -60,7 +141,7 @@ declare interface KeybindingActionConfig {
60
141
  }
61
142
 
62
143
  /** A Client Keybinding Action Binding */
63
- declare interface KeybindingActionBinding {
144
+ interface KeybindingActionBinding {
64
145
  /** The KeyboardEvent#code value from https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values */
65
146
  key: string;
66
147
 
@@ -68,22 +149,44 @@ declare interface KeybindingActionBinding {
68
149
  modifiers?: string[];
69
150
  }
70
151
 
71
- declare interface KeybindingAction {
152
+ /** An action that can occur when a key is pressed */
153
+ interface KeybindingAction {
154
+ /** The namespaced machine identifier of the Action */
72
155
  action: string;
156
+
157
+ /** The Keyboard key */
73
158
  key: string;
159
+
160
+ /** The human readable name */
74
161
  name: string;
162
+
163
+ /** Required modifiers */
75
164
  requiredModifiers: string[];
165
+
166
+ /** Optional (reserved) modifiers */
76
167
  optionalModifiers: string[];
168
+
169
+ /** The handler that executes onDown */
77
170
  onDown: Function;
171
+
172
+ /** The handler that executes onUp */
78
173
  onUp: Function;
174
+
175
+ /** If True, allows Repeat events to execute this Action's onDown */
79
176
  repeat: boolean;
177
+
178
+ /** If true, only a GM can execute this Action */
80
179
  restricted: boolean;
180
+
181
+ /** The registration precedence */
81
182
  precedence: number;
183
+
184
+ /** The registration order */
82
185
  order: number;
83
186
  }
84
187
 
85
188
  /** Keyboard event context */
86
- declare interface KeyboardEventContext {
189
+ interface KeyboardEventContext {
87
190
  /** The normalized string key, such as "A" */
88
191
  key: string;
89
192
 
@@ -115,6 +218,15 @@ declare interface KeyboardEventContext {
115
218
  action: string | undefined;
116
219
  }
117
220
 
221
+ /** Connected Gamepad info */
222
+ interface ConnectedGamepad {
223
+ /** A map of axes values */
224
+ axes: Map<string, number>;
225
+
226
+ /** The Set of pressed Buttons */
227
+ activeButtons: Set<string>;
228
+ }
229
+
118
230
  type RequestData = object | object[] | string | string[];
119
231
 
120
232
  interface SocketRequest {
@@ -183,5 +295,5 @@ interface SocketResponse {
183
295
  /**
184
296
  * An Array of created data objects
185
297
  */
186
- result?: object[];
298
+ result?: object[] | string[];
187
299
  }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * A wrapper method around `fetch` that attaches an AbortController signal to the `fetch` call for clean timeouts
3
+ * @see https://www.npmjs.com/package/node-fetch#request-cancellation-with-abortsignal
4
+ * @param url - The URL to make the Request to
5
+ * @param data - The data of the Request
6
+ * (defalt: `{}`)
7
+ * @param timeoutOptions - (default: `{}`)
8
+ * @throws {@link HttpError}
9
+ */
10
+ export function fetchWithTimeout(
11
+ url: string,
12
+ data?: RequestInit | undefined,
13
+ { timeoutMs, onTimeout }?: TimeoutOptions | undefined
14
+ ): Promise<Response>;
15
+
16
+ /**
17
+ * A small wrapper that automatically asks for JSON
18
+ * @param url - The URL to make the Request to
19
+ * @param data - The data of the Request
20
+ * (defalt: `{}`)
21
+ * @param timeoutOptions - (default: `{}`)
22
+ */
23
+ export function fetchJsonWithTimeout(
24
+ url: string,
25
+ data?: RequestInit | undefined,
26
+ { timeoutMs, onTimeout }?: TimeoutOptions | undefined
27
+ ): Promise<unknown>;
28
+
29
+ /**
30
+ * Represents an HTTP Error when a non-OK response is returned by Fetch
31
+ */
32
+ export class HttpError extends Error {
33
+ constructor(statusText: string, code: number, displayMessage?: string | undefined);
34
+
35
+ code: number;
36
+
37
+ displayMessage: string;
38
+ }
39
+
40
+ interface TimeoutOptions {
41
+ /**
42
+ * How long to wait for a Response before cleanly aborting
43
+ * @defaultValue `30000`
44
+ */
45
+ timeoutMs?: number | undefined;
46
+
47
+ /**
48
+ * A method to invoke if and when the timeout is reached
49
+ * @defaultValue `() => {}`
50
+ */
51
+ onTimeout?: (() => void) | undefined;
52
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './geometry.mjs';
2
2
  export * from './helpers.mjs';
3
+ export * from './http.mjs';
3
4
  export { default as Collection } from './collection.mjs';
4
5
  export { default as Semaphore } from './semaphore.mjs';
@@ -35,6 +35,7 @@ declare class Semaphore {
35
35
  /**
36
36
  * A queue of pending function signatures
37
37
  * @defaultValue `[]`
38
+ * @internal
38
39
  * @remarks The first element of an element of `_queue` is always a function and the rest of the elements are
39
40
  * parameters to be passed to that function.
40
41
  */
@@ -43,6 +44,7 @@ declare class Semaphore {
43
44
  /**
44
45
  * The number of tasks which are currently underway
45
46
  * @defaultValue `0`
47
+ * @internal
46
48
  */
47
49
  protected _active: number;
48
50
 
@@ -60,8 +62,9 @@ declare class Semaphore {
60
62
  * Add a new tasks to the managed queue
61
63
  * @param fn - A callable function
62
64
  * @param args - Function arguments
65
+ * @returns A promise that resolves once the added function is executed
63
66
  */
64
- add<F extends (...args: any[]) => any>(fn: F, ...args: Parameters<F>): void;
67
+ add<F extends (...args: any[]) => any>(fn: F, ...args: Parameters<F>): Promise<Awaited<ReturnType<F>>>;
65
68
 
66
69
  /**
67
70
  * Abandon any tasks which have not yet concluded
@@ -72,9 +75,9 @@ declare class Semaphore {
72
75
  * Attempt to perform a task from the queue.
73
76
  * If all workers are busy, do nothing.
74
77
  * If successful, try again.
75
- * @returns Was a function called?
78
+ * @internal
76
79
  */
77
- protected _try(): Promise<boolean>;
80
+ protected _try(): Promise<false | void>;
78
81
  }
79
82
 
80
83
  export default Semaphore;
@@ -41,7 +41,7 @@ declare global {
41
41
  get title(): string;
42
42
 
43
43
  /**
44
- * A convenience reference to the Actor entity
44
+ * A convenience reference to the Actor document
45
45
  */
46
46
  get actor(): this['object'];
47
47
 
@@ -72,11 +72,6 @@ declare global {
72
72
  */
73
73
  protected _onConfigureToken(event: JQuery.ClickEvent): void;
74
74
 
75
- /**
76
- * Handle requests to configure the default sheet used by this Actor
77
- */
78
- protected _onConfigureSheet(event: JQuery.ClickEvent): void;
79
-
80
75
  /**
81
76
  * Handle changing the actor profile image by opening a FilePicker
82
77
  */
@@ -156,6 +151,13 @@ declare global {
156
151
  event: DragEvent,
157
152
  itemData: foundry.data.ItemData['_source']
158
153
  ): undefined | Promise<InstanceType<ConfiguredDocumentClass<typeof Item>>[]>;
154
+
155
+ /**
156
+ * Is the drop data coming from the same actor?
157
+ * @param data - The drop data.
158
+ * @internal
159
+ */
160
+ protected _isFromSameActor(data: ActorSheet.DropData.Item): Promise<boolean>;
159
161
  }
160
162
 
161
163
  namespace ActorSheet {
@@ -66,20 +66,20 @@ declare global {
66
66
  interface Data {
67
67
  core: {
68
68
  version: string;
69
- menus: ClientSettings.CompleteMenuSetting[];
69
+ menus: SettingSubmenuConfig[];
70
70
  settings: Setting[];
71
71
  none: boolean;
72
72
  };
73
73
  system: {
74
74
  title: Game['system']['data']['title'];
75
- menus: ClientSettings.CompleteMenuSetting[];
75
+ menus: SettingSubmenuConfig[];
76
76
  settings: Setting[];
77
77
  none: boolean;
78
78
  };
79
- modules: { title: string; menus: ClientSettings.CompleteMenuSetting[]; settings: Setting[] }[];
79
+ modules: { title: string; menus: SettingSubmenuConfig[]; settings: Setting[] }[];
80
80
  }
81
81
 
82
- interface Setting extends Omit<ClientSettings.CompleteSetting, 'type'> {
82
+ interface Setting extends Omit<SettingConfig, 'type'> {
83
83
  id: string;
84
84
  name: string;
85
85
  hint: string;
@@ -82,7 +82,7 @@ declare abstract class AVClient {
82
82
  * @param kind - The type of device source being requested
83
83
  * @internal
84
84
  */
85
- _getSourcesOfType(kind: MediaDeviceKind): Promise<Record<string, string>>;
85
+ protected _getSourcesOfType(kind: MediaDeviceKind): Promise<Record<string, string>>;
86
86
 
87
87
  /**
88
88
  * Return an array of Foundry User IDs which are currently connected to A/V.
@@ -98,6 +98,14 @@ declare abstract class AVClient {
98
98
  */
99
99
  abstract getMediaStreamForUser(userId: string): MediaStream | null | undefined;
100
100
 
101
+ /**
102
+ * Provide a MediaStream for monitoring a given user's voice volume levels.
103
+ * @param userId - The User ID.
104
+ * @returns The MediaStream for the user, or null if the user does not have one.
105
+ * @remarks The getLevelsStreamForUser() method must be defined by an AVClient subclass and will be strictly required starting in v10
106
+ */
107
+ getLevelsStreamForUser(userId: string): MediaStream | null | undefined;
108
+
101
109
  /**
102
110
  * Is outbound audio enabled for the current user?
103
111
  */
@@ -141,4 +149,10 @@ declare abstract class AVClient {
141
149
  * @param changed - The settings which have changed
142
150
  */
143
151
  onSettingsChanged(changed: DeepPartial<AVSettings.Settings>): void;
152
+
153
+ /**
154
+ * Replace the local stream for each connected peer with a re-generated MediaStream.
155
+ * @remarks The updateLocalStream() method must be defined by an AVClient subclass.
156
+ */
157
+ abstract updateLocalStream(): Promise<void>;
144
158
  }
@@ -1,2 +1 @@
1
- import './easyRTCClient';
2
1
  import './simplePeerAVClient';
@@ -9,6 +9,12 @@ declare class SimplePeerAVClient extends AVClient {
9
9
  */
10
10
  localStream: MediaStream | null;
11
11
 
12
+ /**
13
+ * The dedicated audio stream used to measure volume levels for voice activity detection.
14
+ * @defaultValue `null`
15
+ */
16
+ levelsStream: MediaStream | null;
17
+
12
18
  /**
13
19
  * A mapping of connected peers
14
20
  */
@@ -24,7 +30,7 @@ declare class SimplePeerAVClient extends AVClient {
24
30
  * @defaultValue `false`
25
31
  * @internal
26
32
  */
27
- _initialized: boolean;
33
+ protected _initialized: boolean;
28
34
 
29
35
  /**
30
36
  * Is outbound broadcast of local audio enabled?
@@ -32,9 +38,21 @@ declare class SimplePeerAVClient extends AVClient {
32
38
  */
33
39
  audioBroadcastEnabled: boolean;
34
40
 
41
+ /**
42
+ * The polling interval ID for connected users that might have unexpectedly dropped out of our peer network.
43
+ * @internal
44
+ */
45
+ protected _connectionPoll: number | null;
46
+
35
47
  /** @override */
36
48
  connect(): Promise<boolean>;
37
49
 
50
+ /**
51
+ * Try to establish a peer connection with each user connected to the server.
52
+ * @internal
53
+ */
54
+ protected _connect(): Promise<SimplePeer.Instance[]>;
55
+
38
56
  /** @override */
39
57
  disconnect(): Promise<boolean>;
40
58
 
@@ -47,6 +65,9 @@ declare class SimplePeerAVClient extends AVClient {
47
65
  /** @override */
48
66
  getMediaStreamForUser(userId: string): MediaStream | null | undefined;
49
67
 
68
+ /** @override */
69
+ getLevelsStreamForUser(userId: string): MediaStream | null | undefined;
70
+
50
71
  /** @override */
51
72
  isAudioEnabled(): boolean;
52
73
 
@@ -70,6 +91,14 @@ declare class SimplePeerAVClient extends AVClient {
70
91
  */
71
92
  initializeLocalStream(): Promise<MediaStream | null>;
72
93
 
94
+ /**
95
+ * Attempt to create local media streams.
96
+ * @param params - Parameters for the getUserMedia request.
97
+ * @returns The created MediaStream or an error.
98
+ * @internal
99
+ */
100
+ protected _createMediaStream(params: MediaStreamConstraints): Promise<MediaStream | Error>;
101
+
73
102
  /**
74
103
  * Listen for Audio/Video updates on the av socket to broker connections between peers
75
104
  */
@@ -131,8 +160,6 @@ declare class SimplePeerAVClient extends AVClient {
131
160
  /** @override */
132
161
  onSettingsChanged(changed: DeepPartial<AVSettings.Settings>): Promise<void>;
133
162
 
134
- /**
135
- * Replace the local stream for each connected peer with a re-generated MediaStream
136
- */
163
+ /** @override */
137
164
  updateLocalStream(): Promise<void>;
138
165
  }
@@ -29,24 +29,26 @@ declare class AVMaster {
29
29
  protected _connected: boolean;
30
30
 
31
31
  /**
32
- * A flag to track whether the A/V system is currently in the process of reconnecting.
33
- * This occurs if the connection is lost or interrupted.
34
- * @defaultValue `false`
32
+ * The cached connection promise.
33
+ * This is required to prevent re-triggering a connection while one is already in progress.
34
+ * @defaultValue `null`
35
35
  * @internal
36
36
  */
37
- protected _reconnecting: boolean;
37
+ protected _connecting: Promise<boolean> | null;
38
38
 
39
39
  /**
40
- * @defaultValue `{}`
40
+ * A flag to track whether the A/V system is currently in the process of reconnecting.
41
+ * This occurs if the connection is lost or interrupted.
42
+ * @defaultValue `false`
41
43
  * @internal
42
44
  */
43
- protected _speakingData: AVMaster.SpeakingData;
45
+ protected _reconnecting: boolean;
44
46
 
45
47
  /**
46
48
  * @defaultValue `{}`
47
49
  * @internal
48
50
  */
49
- protected _pttHandlers: AVMaster.PTTHandlers;
51
+ protected _speakingData: { speaking: boolean; volumeHistories: number[] };
50
52
 
51
53
  /**
52
54
  * @defaultValue `0`
@@ -54,7 +56,7 @@ declare class AVMaster {
54
56
  */
55
57
  protected _pttMuteTimeout: number;
56
58
 
57
- get mode(): AVSettings.VoiceMode;
59
+ get mode(): AVSettings.AV_MODES;
58
60
 
59
61
  /**
60
62
  * Connect to the Audio/Video client.
@@ -111,29 +113,27 @@ declare class AVMaster {
111
113
  * @param mode - The currently selected voice broadcasting mode
112
114
  * @internal
113
115
  */
114
- protected _initializeUserVoiceDetection(mode: AVSettings.VoiceMode): void;
116
+ protected _initializeUserVoiceDetection(mode: AVSettings.VOICE_MODES): void;
115
117
 
116
118
  /**
117
119
  * Activate voice detection tracking for a userId on a provided MediaStream.
118
120
  * Currently only a MediaStream is supported because MediaStreamTrack processing is not yet supported cross-browser.
119
- * @param userId - The Foundry User ID whose voice is being processed
120
121
  * @param stream - The MediaStream which corresponds to that User
121
122
  * @param ms - A number of milliseconds which represents the voice activation volume interval
122
123
  * (default: `CONFIG.WebRTC.detectPeerVolumeInterval`)
123
124
  */
124
- activateVoiceDetection(userId: string, stream: MediaStream, ms?: number): void;
125
+ activateVoiceDetection(stream: MediaStream, ms?: number): void;
125
126
 
126
127
  /**
127
128
  * Actions which the orchestration layer should take when a peer user disconnects from the audio/video service.
128
- * @param userId - The id of the disconnecting User
129
129
  */
130
- deactivateVoiceDetection(userId: string): void;
130
+ deactivateVoiceDetection(): void;
131
131
 
132
132
  /**
133
133
  * Periodic notification of user audio level
134
134
  *
135
- * This function uses the audio level (in dB) of each stream it's listening to to determine if a user
136
- * is speaking or not and notifies the UI of such changes.
135
+ * This function uses the audio level (in dB) of the audio stream to determine if the user is speaking or not and
136
+ * notifies the UI of such changes.
137
137
  *
138
138
  * The User is considered speaking if they are above the decibel threshold in any of the history values.
139
139
  * This marks them as speaking as soon as they have a high enough volume, and marks them as not speaking only after
@@ -142,46 +142,31 @@ declare class AVMaster {
142
142
  * There can be more optimal ways to do this and which uses whether the user was already considered speaking before
143
143
  * or not, in order to eliminate short bursts of audio (coughing for example).
144
144
  *
145
- * @param userId - The user ID of the user whose audio levels are being reported
146
145
  * @param dbLevel - The audio level in decibels of the user within the last 50ms
147
146
  * @internal
148
147
  */
149
- protected _onAudioLevel(userId: string, dbLevel: number): void;
150
-
151
- /**
152
- * Set up interactivity and handling of push-to-talk broadcasting workflow.
153
- * @internal
154
- */
155
- protected _initializePushToTalk(): void;
148
+ protected _onAudioLevel(dbLevel: number): void;
156
149
 
157
150
  /**
158
151
  * Resets the speaking history of a user
159
152
  * If the user was considered speaking, then mark them as not speaking
160
- * @param userId - The ID of the user
161
153
  * @internal
162
154
  */
163
- protected _resetSpeakingHistory(userId: string): void;
155
+ protected _resetSpeakingHistory(): void;
164
156
 
165
157
  /**
166
158
  * Handle activation of a push-to-talk key or button.
167
- * @param event - The original keydown event
159
+ * @param context - The context data of the event
168
160
  * @internal
169
161
  */
170
- _onPTTStart(event: KeyboardEvent | MouseEvent): void;
162
+ _onPTTStart(context: KeyboardEventContext): void;
171
163
 
172
164
  /**
173
165
  * Handle deactivation of a push-to-talk key or button.
174
- * @param event - The original keyup event
166
+ * @param context - The context data of the event
175
167
  * @internal
176
168
  */
177
- _onPTTEnd(event: KeyboardEvent | MouseEvent): void;
178
-
179
- /**
180
- * Handle matching old and new PTT configurations against the mouse or keyboard event.
181
- * @param event - The original event
182
- * @internal
183
- */
184
- _isPTTKey(event: KeyboardEvent | MouseEvent): boolean;
169
+ _onPTTEnd(context: KeyboardEventContext): void;
185
170
 
186
171
  render(): void;
187
172
 
@@ -200,15 +185,3 @@ declare class AVMaster {
200
185
 
201
186
  debug(message: string): void;
202
187
  }
203
-
204
- declare namespace AVMaster {
205
- type SpeakingData = Partial<Record<string, { speaking: boolean; volumeHistories: number[] }>>;
206
- type PTTHandler = (event: KeyboardEvent | MouseEvent) => void;
207
- type PTTHandlers =
208
- | {}
209
- | { mousedown: PTTHandler; mouseup: PTTHandler }
210
- | {
211
- keydown: PTTHandler;
212
- keyup: PTTHandler;
213
- };
214
- }