@@ -11,54 +11,62 @@ import {
1111} from './utils/constants.js' ;
1212
1313/**
14- * The options used for image URLs
14+ * The options used for image URLs.
1515 */
1616export interface BaseImageURLOptions {
1717 /**
18- * The extension to use for the image URL
18+ * The extension to use for the image URL.
1919 *
2020 * @defaultValue `'webp'`
2121 */
2222 extension ?: ImageExtension ;
2323 /**
24- * The size specified in the image URL
24+ * The size specified in the image URL.
2525 */
2626 size ?: ImageSize ;
2727}
2828
29- interface EmojiURLOptionsWebp extends BaseImageURLOptions {
29+ export interface EmojiURLOptionsWebp extends BaseImageURLOptions {
3030 /**
3131 * Whether to use the `animated` query parameter.
32- *
33- * @remarks An animated custom emoji with the WebP format utilises this query paramter to be animated.
3432 */
3533 animated ?: boolean ;
3634 extension ?: 'webp' ;
3735}
3836
39- interface EmojiURLOptionsNotWebP extends BaseImageURLOptions {
37+ export interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
4038 extension : Exclude < ImageExtension , 'webp' > ;
4139}
4240
4341/**
4442 * The options used for emoji URLs.
4543 */
46- export type EmojiURLOptions = EmojiURLOptionsNotWebP | EmojiURLOptionsWebp ;
44+ export type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp ;
4745
48- /**
49- * The options used for image URLs with animated content
50- */
51- export interface ImageURLOptions extends BaseImageURLOptions {
46+ export interface BaseAnimatedImageURLOptions extends BaseImageURLOptions {
5247 /**
53- * Whether or not to prefer the static version of an image asset.
48+ * Whether to prefer the static asset.
5449 */
5550 forceStatic ?: boolean ;
5651}
5752
53+ export interface ImageURLOptionsWebp extends BaseAnimatedImageURLOptions {
54+ extension ?: 'webp' ;
55+ }
56+
57+ export interface ImageURLOptionsNotWebp extends BaseAnimatedImageURLOptions {
58+ extension : Exclude < ImageExtension , 'webp' > ;
59+ }
60+
61+ /**
62+ * The options used for image URLs that may be animated.
63+ */
64+ export type ImageURLOptions = ImageURLOptionsNotWebp | ImageURLOptionsWebp ;
65+
5866/**
5967 * The options to use when making a CDN URL
6068 */
61- export interface MakeURLOptions {
69+ interface MakeURLOptions {
6270 /**
6371 * The allowed extensions that can be used
6472 */
@@ -332,7 +340,7 @@ export class CDN {
332340 hash : string ,
333341 { forceStatic = false , ...options } : Readonly < ImageURLOptions > = { } ,
334342 ) : string {
335- return this . makeURL ( route , ! forceStatic && hash . startsWith ( 'a_' ) ? { ...options , extension : 'gif' } : options ) ;
343+ return this . makeURL ( route , ! forceStatic && hash . startsWith ( 'a_' ) ? { ...options , animated : true } : options ) ;
336344 }
337345
338346 /**
@@ -364,14 +372,14 @@ export class CDN {
364372
365373 const url = new URL ( `${ base } ${ route } .${ extension } ` ) ;
366374
367- if ( size ) {
368- url . searchParams . set ( 'size' , String ( size ) ) ;
369- }
370-
371375 if ( animated !== undefined ) {
372376 url . searchParams . set ( 'animated' , String ( animated ) ) ;
373377 }
374378
379+ if ( size ) {
380+ url . searchParams . set ( 'size' , String ( size ) ) ;
381+ }
382+
375383 return url . toString ( ) ;
376384 }
377385}
0 commit comments