@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250721081834 → 13.346.0-beta.20250722114330

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@league-of-foundry-developers/foundry-vtt-types",
4
- "version": "13.346.0-beta.20250721081834",
4
+ "version": "13.346.0-beta.20250722114330",
5
5
  "description": "TypeScript type definitions for Foundry VTT",
6
6
  "type": "module",
7
7
  "types": "./src/index.d.mts",
@@ -1,3 +1,5 @@
1
+ import type { Brand, Coalesce } from "#utils";
2
+
1
3
  /**
2
4
  * A common framework for displaying notifications to the client.
3
5
  * Submitted notifications are added to a queue, and up to {@link Notifications.MAX_ACTIVE} notifications are
@@ -47,38 +49,35 @@ declare class Notifications {
47
49
  * @returns The ID of the notification (positive integer)
48
50
  * @remarks `type` and `options` use parameter defaults so `null` causes an error
49
51
  */
50
- notify<T extends Notifications.Type = "info">(
52
+ notify<T extends Notifications.Type | undefined = undefined>(
51
53
  message: string,
52
54
  type?: T,
53
55
  options?: Notifications.NotifyOptions,
54
- ): Readonly<Notifications.Notification<T>>;
56
+ ): Notifications.Notification<Coalesce<T, "info">>;
55
57
 
56
58
  /**
57
59
  * Display a notification with the "info" type
58
60
  * @param message - The content of the notification message
59
61
  * @param options - Notification options passed to the notify function
60
- * @returns The ID of the notification (positive integer)
61
- * @remarks `options` use parameter defaults so `null` causes an error
62
+ * @returns The registered notification
62
63
  */
63
- info(message: string, options?: Notifications.NotifyOptions): Readonly<Notifications.Notification<"info">>;
64
+ info(message: string, options?: Notifications.NotifyOptions): Notifications.Notification<"info">;
64
65
 
65
66
  /**
66
67
  * Display a notification with the "warning" type
67
68
  * @param message - The content of the notification message
68
69
  * @param options - Notification options passed to the notify function
69
- * @returns The ID of the notification (positive integer)
70
- * @remarks `options` use parameter defaults so `null` causes an error
70
+ * @returns The registered notification
71
71
  */
72
- warn(message: string, options?: Notifications.NotifyOptions): Readonly<Notifications.Notification<"warning">>;
72
+ warn(message: string, options?: Notifications.NotifyOptions): Notifications.Notification<"warning">;
73
73
 
74
74
  /**
75
75
  * Display a notification with the "error" type
76
76
  * @param message - The content of the notification message
77
77
  * @param options - Notification options passed to the notify function
78
- * @returns The ID of the notification (positive integer)
79
- * @remarks `options` use parameter defaults so `null` causes an error
78
+ * @returns The registered notification
80
79
  */
81
- error(message: string, options?: Notifications.NotifyOptions): Readonly<Notifications.Notification<"error">>;
80
+ error(message: string, options?: Notifications.NotifyOptions): Notifications.Notification<"error">;
82
81
 
83
82
  /**
84
83
  * Display a notification with the "success" type.
@@ -86,27 +85,34 @@ declare class Notifications {
86
85
  * @param options - Notification options passed to the notify function
87
86
  * @returns The registered notification
88
87
  */
89
- success(message: string, options?: Notifications.NotifyOptions): Readonly<Notifications.Notification<"success">>;
88
+ success(message: string, options?: Notifications.NotifyOptions): Notifications.Notification<"success">;
90
89
 
91
90
  /**
92
91
  * Update the progress of the notification.
93
92
  * @param notification - A Notification or ID to update
94
93
  * @param update - An incremental progress update
95
94
  */
96
- update(notification: Notifications.Notification | number, update: Notifications.UpdateOptions): void;
95
+ update(notification: Notifications.Notification | Notifications.ID, update: Notifications.UpdateOptions): void;
97
96
 
98
97
  /**
99
98
  * Remove the notification linked to the ID.
100
99
  * @param id - The Notification or ID to remove
101
100
  */
102
- remove(id: Notifications.Notification | number): void;
101
+ remove(id: Notifications.Notification | Notifications.ID): void;
102
+
103
+ /**
104
+ * Does the notification linked to the ID exist?.
105
+ * @param notification - The Notification or ID to remove
106
+ * @remarks Foundry writing "The Notification or ID to remove" is likely unintentional.
107
+ */
108
+ has(id: Notifications.Notification | Notifications.ID): boolean;
103
109
 
104
110
  /**
105
111
  * Clear all notifications.
106
112
  */
107
113
  clear(): void;
108
114
 
109
- #private: true;
115
+ #Notifications: true;
110
116
  }
111
117
 
112
118
  declare abstract class AnyNotifications extends Notifications {
@@ -119,8 +125,10 @@ declare namespace Notifications {
119
125
 
120
126
  type Type = "info" | "warning" | "error" | "success";
121
127
 
128
+ type ID = Brand<number, "Notifications.ID">;
129
+
122
130
  interface Notification<T extends Type = Type> {
123
- id: number;
131
+ id: Notifications.ID;
124
132
  type: T;
125
133
  timestamp: number;
126
134
  message: string;
@@ -129,79 +137,74 @@ declare namespace Notifications {
129
137
  active: boolean;
130
138
  progress: boolean;
131
139
  pct: number;
132
- element?: HTMLLIElement;
133
- remove?: () => void;
134
- update?: (pct: number) => void;
140
+ element?: HTMLLIElement | undefined;
141
+ remove?: (() => void) | undefined;
142
+ update?: ((update: Notifications.UpdateOptions) => void) | undefined;
135
143
  }
136
144
 
137
145
  interface FormatOptions {
138
146
  /**
139
147
  * Whether to escape the values of `format`
140
148
  * @defaultValue `true`
141
- * @remarks `null` equivalent to `false`
142
149
  */
143
- escape?: boolean | null | undefined;
150
+ escape?: boolean | undefined;
144
151
 
145
152
  /**
146
153
  * Whether to clean the provided message string as untrusted user input.
147
154
  * No cleaning is applied if `format` is passed and `escape` is true or `localize` is true and `format` is not passed.
148
155
  * @defaultValue `true`
149
- * @remarks `null` equivalent to `false`
150
156
  */
151
- clean?: boolean | null | undefined;
157
+ clean?: boolean | undefined;
152
158
 
153
159
  /**
154
160
  * A mapping of formatting strings passed to Localization#format
155
161
  */
156
- format?: Record<string, string> | null | undefined;
162
+ format?: Record<string, string> | undefined;
157
163
  }
158
164
 
159
165
  interface NotifyOptions extends FormatOptions {
160
166
  /**
161
167
  * Should the notification be permanently displayed until dismissed
162
168
  * @defaultValue `false`
163
- * @remarks Overridden as `true` if `progress` is true. `null` equivalent to `false`
164
169
  */
165
- permanent?: boolean | null | undefined;
170
+ permanent?: boolean | undefined;
166
171
 
167
172
  /**
168
173
  * Does this Notification include a progress bar?
169
174
  * @defaultValue `false`
170
- * @remarks `null` equivalent to `false`
171
175
  */
172
- progress?: boolean | null | undefined;
176
+ progress?: boolean | undefined;
173
177
 
174
178
  /**
175
179
  * Whether to localize the message content before displaying it
176
180
  * @defaultValue `false`
177
181
  */
178
- localize?: boolean;
182
+ localize?: boolean | undefined;
179
183
 
180
184
  /**
181
185
  * Whether to log the message to the console
182
186
  * @defaultValue `true`
183
- * @remarks `null` equivalent to `false`
184
187
  */
185
- console?: boolean | null | undefined;
188
+ console?: boolean | undefined;
186
189
  }
187
190
 
188
191
  interface UpdateOptions extends FormatOptions {
189
192
  /**
190
193
  * An update to the string message
191
194
  */
192
- message?: string | null | undefined;
195
+ message?: string | undefined;
193
196
 
194
197
  /**
195
198
  * Localize updates to presented progress text
196
199
  * @defaultValue `false`
197
- * @remarks `null` equivalent to `false`
198
200
  */
199
- localize?: boolean | null | undefined;
201
+ localize?: boolean | undefined;
200
202
 
201
203
  /**
202
204
  * An update to the completion percentage
205
+ * @remarks Only allows numbers in the range `[0, 1]`
203
206
  */
204
- pct?: number | null | undefined;
207
+ pct?: number | undefined;
205
208
  }
206
209
  }
207
210