import { FaviconHtmlElement } from "../index.js" ; import { FaviconOptions , IconOptions } from "../config/defaults.js" ; import { opaqueIcon } from "../config/icons.js" ; import { Dictionary } from "../helpers.js" ; import { logContext , Logger } from "../logger.js" ; import { Platform , uniformIconOptions } from "./base.js" ; interface ScreenSize { readonly deviceWidth : number ; readonly deviceHeight : number ; readonly pixelRatio : number ; } const SCREEN_SIZES = [ { deviceWidth : 320 , deviceHeight : 568 , pixelRatio : 2 } , { deviceWidth : 375 , deviceHeight : 667 , pixelRatio : 2 } , { deviceWidth : 375 , deviceHeight : 812 , pixelRatio : 3 } , { deviceWidth : 390 , deviceHeight : 844 , pixelRatio : 3 } , { deviceWidth : 414 , deviceHeight : 896 , pixelRatio : 2 } , { deviceWidth : 414 , deviceHeight : 896 , pixelRatio : 3 } , { deviceWidth : 414 , deviceHeight : 736 , pixelRatio : 3 } , { deviceWidth : 414 , deviceHeight : 736 , pixelRatio : 3 } , { deviceWidth : 428 , deviceHeight : 926 , pixelRatio : 3 } , { deviceWidth : 768 , deviceHeight : 1024 , pixelRatio : 2 } , { deviceWidth : 810 , deviceHeight : 1080 , pixelRatio : 2 } , { deviceWidth : 834 , deviceHeight : 1194 , pixelRatio : 2 } , { deviceWidth : 834 , deviceHeight : 1112 , pixelRatio : 2 } , { deviceWidth : 1024 , deviceHeight : 1366 , pixelRatio : 2 } , ] ; interface AppleStartupImage extends IconOptions , ScreenSize { readonly orientation : string ; } function iconOptions ( ) { const result = { } ; for ( const size of SCREEN_SIZES ) { const pixelWidth = size . deviceWidth * size . pixelRatio ; const pixelHeight = size . deviceHeight * size . pixelRatio ; result [ `apple-touch-startup-image-${ pixelWidth }x${ pixelHeight }.png` ] = { ... opaqueIcon ( pixelWidth , pixelHeight ) , ... size , orientation : "portrait" , } ; result [ `apple-touch-startup-image-${ pixelHeight }x${ pixelWidth }.png` ] = { ... opaqueIcon ( pixelHeight , pixelWidth ) , ... size , orientation : "landscape" , } ; } return result ; } const ICONS_OPTIONS = iconOptions ( ) ; export class AppleStartupPlatform extends Platform < AppleStartupImage > { constructor ( options , logger ) { super ( options , uniformIconOptions ( options , options . icons . appleStartup , ICONS_OPTIONS ) , logContext ( logger , "appleStartup" ) ) ; } async createHtml ( ) { return Object . entries ( this . iconOptions ) . map ( ( [ name , item ] ) => `<link rel="apple-touch-startup-image" media="(device-width: ${ item . deviceWidth }px) and (device-height: ${ item . deviceHeight }px) and (-webkit-device-pixel-ratio: ${ item . pixelRatio }) and (orientation: ${ item . orientation })" href="${ this . relative ( name ) }">` ) ; } }