@league-of-foundry-developers/foundry-vtt-types 9.249.3 → 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 (63) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/foundry/common/constants.mjs.d.ts +1 -0
  4. package/src/foundry/common/documents.mjs/baseMacro.d.ts +0 -3
  5. package/src/foundry/common/documents.mjs/baseMeasuredTemplate.d.ts +8 -1
  6. package/src/foundry/common/packages.mjs/packageCompendiumData.d.ts +7 -1
  7. package/src/foundry/common/types.mjs.d.ts +120 -8
  8. package/src/foundry/common/utils/helpers.mjs.d.ts +0 -1
  9. package/src/foundry/common/utils/http.mjs.d.ts +52 -0
  10. package/src/foundry/common/utils/module.mjs.d.ts +1 -0
  11. package/src/foundry/common/utils/primitives.mjs.d.ts +2 -2
  12. package/src/foundry/common/utils/semaphore.mjs.d.ts +6 -3
  13. package/src/foundry/foundry.js/applications/formApplications/documentSheets/actorSheet.d.ts +8 -6
  14. package/src/foundry/foundry.js/applications/formApplications/documentSheets/itemSheet.d.ts +1 -1
  15. package/src/foundry/foundry.js/applications/formApplications/settingsConfig.d.ts +4 -4
  16. package/src/foundry/foundry.js/applications/notifications.d.ts +2 -5
  17. package/src/foundry/foundry.js/avClient.d.ts +15 -1
  18. package/src/foundry/foundry.js/avClients/index.d.ts +0 -1
  19. package/src/foundry/foundry.js/avClients/simplePeerAVClient.d.ts +31 -4
  20. package/src/foundry/foundry.js/avMaster.d.ts +21 -48
  21. package/src/foundry/foundry.js/avSettings.d.ts +19 -46
  22. package/src/foundry/foundry.js/canvas.d.ts +0 -8
  23. package/src/foundry/foundry.js/clientDatabaseBackend.d.ts +6 -0
  24. package/src/foundry/foundry.js/clientDocumentMixin.d.ts +2 -2
  25. package/src/foundry/foundry.js/clientDocuments/activeEffect.d.ts +28 -6
  26. package/src/foundry/foundry.js/clientDocuments/actor.d.ts +13 -70
  27. package/src/foundry/foundry.js/clientDocuments/canvasDocuments/tokenDocument.d.ts +42 -9
  28. package/src/foundry/foundry.js/clientDocuments/cards.d.ts +2 -1
  29. package/src/foundry/foundry.js/clientDocuments/folder.d.ts +22 -20
  30. package/src/foundry/foundry.js/clientDocuments/item.d.ts +5 -23
  31. package/src/foundry/foundry.js/clientDocuments/macro.d.ts +10 -0
  32. package/src/foundry/foundry.js/clientDocuments/playlistSound.d.ts +1 -1
  33. package/src/foundry/foundry.js/clientDocuments/prototypeToken.d.ts +24 -14
  34. package/src/foundry/foundry.js/clientDocuments/rollTable.d.ts +16 -14
  35. package/src/foundry/foundry.js/clientDocuments/scene.d.ts +12 -7
  36. package/src/foundry/foundry.js/clientDocuments/user.d.ts +2 -12
  37. package/src/foundry/foundry.js/clientSettings.d.ts +203 -230
  38. package/src/foundry/foundry.js/collections/documentCollections/compendiumCollection.d.ts +3 -1
  39. package/src/foundry/foundry.js/config.d.ts +3 -0
  40. package/src/foundry/foundry.js/game.d.ts +1 -1
  41. package/src/foundry/foundry.js/gamepadManager.d.ts +12 -0
  42. package/src/foundry/foundry.js/globalVariables.d.ts +0 -31
  43. package/src/foundry/foundry.js/pixi/containers/baseGrid.d.ts +21 -6
  44. package/src/foundry/foundry.js/pixi/containers/baseGrids/hexagonalGrid.d.ts +13 -8
  45. package/src/foundry/foundry.js/pixi/containers/baseGrids/squareGrid.d.ts +5 -3
  46. package/src/foundry/foundry.js/pixi/containers/canvasLayers/gridLayer.d.ts +14 -5
  47. package/src/foundry/foundry.js/pixi/containers/placeableObject.d.ts +9 -55
  48. package/src/foundry/foundry.js/pixi/containers/placeableObjects/ambientSound.d.ts +3 -0
  49. package/src/foundry/foundry.js/pixi/containers/placeableObjects/drawing.d.ts +3 -0
  50. package/src/foundry/foundry.js/pixi/containers/placeableObjects/measuredTemplate.d.ts +3 -0
  51. package/src/foundry/foundry.js/pixi/containers/placeableObjects/note.d.ts +3 -0
  52. package/src/foundry/foundry.js/pixi/containers/placeableObjects/tile.d.ts +3 -0
  53. package/src/foundry/foundry.js/pixi/containers/placeableObjects/token.d.ts +3 -0
  54. package/src/foundry/foundry.js/pixi/polygons/pointSourcePolygon.d.ts +4 -2
  55. package/src/foundry/foundry.js/pixi/polygons/pointSourcePolygons/clockwiseSweepPolygon.d.ts +31 -17
  56. package/src/foundry/foundry.js/rollTerms/diceTerms/die.d.ts +0 -5
  57. package/src/foundry/foundry.js/rollTerms/diceTerms/fateDie.d.ts +21 -1
  58. package/src/foundry/foundry.js/videoHelper.d.ts +0 -7
  59. package/src/foundry/index.d.ts +0 -4
  60. package/src/types/helperTypes.d.ts +6 -0
  61. package/src/foundry/foundry.js/avClients/easyRTCClient.d.ts +0 -392
  62. package/src/foundry/foundry.js/features.d.ts +0 -0
  63. 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.249.3",
3
+ "version": "9.255.1",
4
4
  "description": "TypeScript type definitions for Foundry VTT",
5
5
  "exports": {
6
6
  ".": {
@@ -74,7 +74,7 @@
74
74
  "lint-staged": "^12.1.2",
75
75
  "prettier": "^2.5.1",
76
76
  "tsd": "^0.19.1",
77
- "typescript": "~4.5.3"
77
+ "typescript": "~4.6.2"
78
78
  },
79
79
  "husky": {
80
80
  "hooks": {
@@ -817,6 +817,7 @@ export const TEXT_FILE_EXTENSIONS: Readonly<{
817
817
  md: 'text/markdown';
818
818
  pdf: 'application/pdf';
819
819
  txt: 'text/plain';
820
+ xml: 'application/xml';
820
821
  }>;
821
822
  export type TEXT_FILE_EXTENSIONS = ValueOf<typeof TEXT_FILE_EXTENSIONS>;
822
823
 
@@ -16,9 +16,6 @@ type MacroMetadata = Merge<
16
16
  types: [typeof CONST.MACRO_TYPES.SCRIPT, typeof CONST.MACRO_TYPES.CHAT];
17
17
  permissions: {
18
18
  create: 'PLAYER';
19
- // TODO: fix when fixed by foundry (https://gitlab.com/foundrynet/foundryvtt/-/issues/6694)
20
- // update: undefined;
21
- // delete: undefined;
22
19
  };
23
20
  }
24
21
  >;
@@ -15,7 +15,7 @@ type MeasuredTemplateMetadata = Merge<
15
15
  labelPlural: 'DOCUMENT.MeasuredTemplates';
16
16
  isEmbedded: true;
17
17
  permissions: {
18
- create: 'TEMPLATE_CREATE';
18
+ create: (user: BaseUser, doc: BaseMeasuredTemplate) => boolean;
19
19
  update: (
20
20
  user: BaseUser,
21
21
  doc: BaseMeasuredTemplate,
@@ -51,6 +51,13 @@ export declare class BaseMeasuredTemplate extends Document<
51
51
  { exact }?: { exact?: boolean }
52
52
  ): boolean;
53
53
 
54
+ /**
55
+ * Is a user able to create a new MeasuredTemplate?
56
+ * @param user - The user attempting the creation operation.
57
+ * @param doc - The MeasuredTemplate being created.
58
+ */
59
+ protected static _canCreate(user: BaseUser, doc: BaseMeasuredTemplate): boolean;
60
+
54
61
  /**
55
62
  * Is a user able to modify an existing MeasuredTemplate?
56
63
  */
@@ -3,7 +3,13 @@ import { DocumentData } from '../abstract/module.mjs';
3
3
  import * as fields from '../data/fields.mjs';
4
4
 
5
5
  interface PackageCompendiumDataSchema extends DocumentSchema {
6
- name: fields.RequiredString;
6
+ name: FieldReturnType<
7
+ fields.RequiredString,
8
+ {
9
+ validate: (v: string) => boolean;
10
+ validationError: "Invalid compendium name '{value}'. Compendium names cannot contain dots.";
11
+ }
12
+ >;
7
13
  label: fields.RequiredString;
8
14
  path: fields.RequiredString;
9
15
  private: FieldReturnType<fields.BooleanField, { default: false }>;
@@ -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
  }
@@ -441,7 +441,6 @@ export declare function setProperty(object: object, key: string, value: any): bo
441
441
 
442
442
  /**
443
443
  * Express a timestamp as a relative string
444
- * TODO - figure out a way to localize this
445
444
  * @param timeStamp - A timestamp string or Date object to be formatted as a relative time
446
445
  * @returns A string expression for the relative time
447
446
  */
@@ -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';
@@ -201,10 +201,10 @@ interface NumberConstructor {
201
201
 
202
202
  /**
203
203
  * Attempt to create a number from a user-provided string.
204
- * @param str - The string.
204
+ * @param n - The value to convert; typically a string, but may already be a number.
205
205
  * @returns The number that the string represents, or NaN if no number could be determined.
206
206
  */
207
- fromString(str: string): number;
207
+ fromString(str: string | number): number;
208
208
  }
209
209
 
210
210
  interface ArrayConstructor {
@@ -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 {
@@ -39,7 +39,7 @@ declare global {
39
39
  /**
40
40
  * A convenience reference to the Item entity
41
41
  */
42
- get item(): InstanceType<ConfiguredDocumentClass<typeof Item>>;
42
+ get item(): this['object'];
43
43
 
44
44
  /**
45
45
  * The Actor instance which owns this item. This may be null if the item is
@@ -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;
@@ -46,11 +46,8 @@ declare class Notifications<Options extends ApplicationOptions = ApplicationOpti
46
46
  */
47
47
  initialize(): void;
48
48
 
49
- /**
50
- * @override
51
- * @remarks This return a `JQuery`, which is incompatible with the expected `Promise<JQuery>` (see https://gitlab.com/foundrynet/foundryvtt/-/issues/6554).
52
- */
53
- protected _renderInner(data: object): any;
49
+ /** @override */
50
+ protected _renderInner(data: object): Promise<JQuery>;
54
51
 
55
52
  /** @override */
56
53
  protected _render(force?: boolean, options?: Application.RenderOptions<Options>): Promise<void>;
@@ -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
  }