@@ -14,27 +14,44 @@ import { deprecationWarning } from './utils/utils.js';
1414let deprecationEmittedForEmoji = false ;
1515
1616/**
17- * The options used for image URLs
17+ * The options used for image URLs.
1818 */
1919export interface BaseImageURLOptions {
2020 /**
21- * The extension to use for the image URL
21+ * The extension to use for the image URL.
2222 *
2323 * @defaultValue `'webp'`
2424 */
2525 extension ?: ImageExtension ;
2626 /**
27- * The size specified in the image URL
27+ * The size specified in the image URL.
2828 */
2929 size ?: ImageSize ;
3030}
3131
32+ export interface EmojiURLOptionsWebp extends BaseImageURLOptions {
33+ /**
34+ * Whether to use the `animated` query parameter.
35+ */
36+ animated ?: boolean ;
37+ extension ?: 'webp' ;
38+ }
39+
40+ export interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
41+ extension : Exclude < ImageExtension , 'webp' > ;
42+ }
43+
3244/**
33- * The options used for image URLs with animated content
45+ * The options used for emoji URLs.
46+ */
47+ export type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp ;
48+
49+ /**
50+ * The options used for image URLs that may be animated.
3451 */
3552export interface ImageURLOptions extends BaseImageURLOptions {
3653 /**
37- * Whether or not to prefer the static version of an image asset.
54+ * Whether to prefer the static asset.
3855 */
3956 forceStatic ?: boolean ;
4057}
@@ -47,6 +64,10 @@ export interface MakeURLOptions {
4764 * The allowed extensions that can be used
4865 */
4966 allowedExtensions ?: readonly string [ ] ;
67+ /**
68+ * Whether to use the `animated` query parameter
69+ */
70+ animated ?: boolean ;
5071 /**
5172 * The base URL.
5273 *
@@ -192,7 +213,7 @@ export class CDN {
192213 * @param emojiId - The emoji id
193214 * @param options - Optional options for the emoji
194215 */
195- public emoji ( emojiId : string , options ?: Readonly < BaseImageURLOptions > ) : string ;
216+ public emoji ( emojiId : string , options ?: Readonly < EmojiURLOptions > ) : string ;
196217
197218 /**
198219 * Generates an emoji's URL for an emoji.
@@ -204,7 +225,7 @@ export class CDN {
204225 // eslint-disable-next-line @typescript-eslint/unified-signatures
205226 public emoji ( emojiId : string , extension ?: ImageExtension ) : string ;
206227
207- public emoji ( emojiId : string , options ?: ImageExtension | Readonly < BaseImageURLOptions > ) : string {
228+ public emoji ( emojiId : string , options ?: ImageExtension | Readonly < EmojiURLOptions > ) : string {
208229 let resolvedOptions ;
209230
210231 if ( typeof options === 'string' ) {
@@ -381,6 +402,7 @@ export class CDN {
381402 base = this . cdn ,
382403 extension = 'webp' ,
383404 size,
405+ animated,
384406 } : Readonly < MakeURLOptions > = { } ,
385407 ) : string {
386408 // eslint-disable-next-line no-param-reassign
@@ -396,6 +418,10 @@ export class CDN {
396418
397419 const url = new URL ( `${ base } ${ route } .${ extension } ` ) ;
398420
421+ if ( animated !== undefined ) {
422+ url . searchParams . set ( 'animated' , String ( animated ) ) ;
423+ }
424+
399425 if ( size ) {
400426 url . searchParams . set ( 'size' , String ( size ) ) ;
401427 }
0 commit comments