/******************************** * Incoming Events (JS -> App) ********************************/ // Sent by the app as soon as it is ready to receive events. export type InitializeEvent = { eventType: 'Initialize'; payload: { // Controls if autoplay should be enabled. autoplay: boolean; // Defines what content should be excluded (e.g. sport). excludedContent: string[]; // A unique identifier of the device, used to identify the device // across multiple page views in the web view. deviceId?: string; // A unique identifier of the app, used to distinguish the different // apps accessing the webviews. // It comes in the form: srf-app-{product}-{OS}-{status} // where product is either: "news,sport,meteo" // where OS is either: "ios,android" // where status is either "beta" or empty (meaning last '-' would not be present) // examples: srf-app-news-ios, srf-app-meteo-android-beta appId?: string; appVersion?: string; // Enables the debug mode of the bridge (currently only logging). debugMode?: boolean; // (Dynamic) text size. scaleFactor?: number; // Usercentrics userSessionData as base64 encoded String (provided by mobile SDKs) usercentricsUserSessionData?: string; // Authentication information consisting of access tokens and app client IDs (token scopes). authenticationItems?: AuthenticationItem[]; }; }; // Used to enable or disable autoplay of videos in the web view. export type SetAutoplayEvent = { eventType: 'SetAutoplay'; payload: { autoplay: boolean; }; }; // Used to exclude content in the web view (e.g. sport-related content). export type SetExcludedContentEvent = { eventType: 'SetExcludedContent'; payload: { value: string[]; }; }; // Anchor name which the Webview is scrolling to when ready. export type JumpToAnchorEvent = { eventType: 'JumpToAnchor'; payload: { anchor: string; }; }; // Update the device info. export type DeviceInfoEvent = { eventType: 'DeviceInfo'; payload: { deviceId?: string; siteName?: string; }; }; // Change the view mode. export type SetViewModeEvent = { eventType: 'SetViewMode'; payload: { isCompact: boolean; }; }; // Set the user location. export type SetUserLocationEvent = { eventType: 'SetUserLocation'; payload: { latitude: number; longitude: number; }; }; type MeteoFavorite = { id: string; latitude: number; longitude: number; }; // Set meteo favorite locations export type SetMeteoFavoritesEvent = { eventType: 'SetMeteoFavorites'; payload: { favorites: MeteoFavorite[]; }; }; // Used to set the current selected image in the image gallery by index export type SetImageGalleryIndexEvent = { eventType: 'SetImageGalleryIndex'; payload: SetImageGalleryIndex; }; // Change the (dynamic) text size. export type SetTextSizeEvent = { eventType: 'SetTextSize'; payload: { scaleFactor: number; }; }; // Media playback state changed (video/ audio is stopped or continued) export type MediaPlaybackStatusEvent = { eventType: 'MediaPlaybackStatus'; payload: { playbackState: PlaybackState; urn: string; }; }; // Used to pass authentication information to the web view. export type SetAuthenticationItemsEvent = { eventType: 'SetAuthenticationItems'; payload: { authenticationItems?: AuthenticationItem[]; }; }; // all events that can be received FROM the app export type IncomingEvent = | InitializeEvent | SetAutoplayEvent | JumpToAnchorEvent | DeviceInfoEvent | MediaPlaybackStatusEvent | SetImageGalleryIndexEvent | SetTextSizeEvent | SetViewModeEvent | SetUserLocationEvent | SetMeteoFavoritesEvent | SetAuthenticationItemsEvent; /******************************** * Outgoing Events (JS -> App) ********************************/ // This is an iOS specific event to signal that the web view is ready // to handle events. Android handle the call to SRFApp.init() for the same // purpose. export type Ready = { eventType: 'Ready'; payload: {}; }; // The web view sends this event for every page. export type PageMetaDataEvent = { eventType: 'PageMetaData'; payload: PageMetaData; }; // Used to track events on the web view after the initial page load. // This can be anything from a tap on a button, to scrolling down to the // end of an article or tracking a "quality visit" when the user has been // looking long enough on a page. export type TrackingEvent = { eventType: 'TrackingEvent'; payload: TrackingEventPayload; }; // Used to track events on the web view after the initial page load. // These are extended TrackingEvents only tracked by UDP. export type WebToUDPTrackingEvent = { eventType: 'WebToUDPTrackingEvent'; payload: WebToUDPTrackingEventPayload; }; // Requests the app to open a native video player and play // the video with the given urn at the specified start position. export type PlayVideoEvent = { eventType: 'PlayVideo'; payload: PlayVideoPayload; }; // Requests the app to open a native audio player and play // the audio with the given urn at the specified start position. export type PlayAudioEvent = { eventType: 'PlayAudio'; payload: PlayAudioPayload; }; // Requests the app to open a native audio or video player and play // the livestream with the given urn. export type PlayLivestreamEvent = { eventType: 'PlayLivestream'; payload: PlayLivestreamPayload; }; // Requests the app to open a native image gallery. export type OpenImageGalleryEvent = { eventType: 'OpenImageGallery'; payload: { // Identifier for the gallery galleryId?: string; // The 0-based index of the image to show initially. currentIndex: number; // The position of the gallery on screen. position: Rect; // The images in the gallery. entries: ImageEntry[]; }; }; export type OpenArticleEvent = { eventType: 'OpenArticle'; payload: { urn: string; url: string; title: string; anchor?: string; }; }; export type OpenLandingPageEvent = { eventType: 'OpenLandingPage'; payload: { urn: string; url: string; title: string; }; }; export type OpenLinkEvent = { eventType: 'OpenLink'; payload: { url: string; title?: string; }; }; export type OpenLiveCenterEvent = { eventType: 'OpenLiveCenter'; payload: { urn: string; }; }; export type PlayOlympicsStreamEvent = { eventType: 'PlayOlympicsStream'; payload: { streamUrn: string; eventId?: string; sportKey?: string; }; }; export type PlayHighlightEvent = { eventType: 'PlayHighlight'; payload: { urn: string; startTime: number; // Highlight start time in seconds since epoch unix. }; }; // Informs the app about the current view mode export type InformViewModeEvent = { eventType: 'InformViewMode'; payload: { isCompact: boolean; }; }; // Informs the app whether the current viewport contains a swipeable collection. export type SwipeableStatusEvent = { eventType: 'SwipeableStatus'; payload: { swipeableInViewport: boolean; }; }; // Requests authentication for given client identifier. export type RequestAuthenticationEvent = { eventType: 'RequestAuthentication'; payload: { clientId: string; }; }; // Requests logout for given client identifiers. export type RequestLogoutEvent = { eventType: 'RequestLogout'; payload: { clientIds: string[]; }; }; // Requests showing user profile. export type OpenProfileEvent = { eventType: 'OpenProfile'; payload: {}; }; // all events that can be sent TO the app export type OutgoingEvent = | Ready | PageMetaDataEvent | TrackingEvent | WebToUDPTrackingEvent | PlayVideoEvent | PlayAudioEvent | PlayLivestreamEvent | MediaPlaybackStatusEvent | OpenImageGalleryEvent | OpenArticleEvent | OpenLandingPageEvent | OpenLinkEvent | OpenLiveCenterEvent | PlayOlympicsStreamEvent | PlayHighlightEvent | InformViewModeEvent | SwipeableStatusEvent | CommentsInfoEvent | RequestAuthenticationEvent | RequestLogoutEvent | OpenProfileEvent; type ImageEntry = { index: number; url: string; // deprecated, use image instead image: Image; title?: string; alt?: string; description?: string; source?: string; sourceUrl?: string; sourceUrn?: string; placeholderData?: string; link?: string; linkUrl?: string; linkUrn?: string; }; type Image = { id: string; provider: ImageProvider; }; enum ImageProvider { Rokka = 'rokka', IL_Image_Service = 'il', } export type AuthenticationItem = { accessToken: string; clientId: string; }; type Rect = { height: number; width: number; x: number; y: number; top: number; left: number; right: number; bottom: number; }; export type PageMetaData = { title: string; weburl: string; shortLead?: string; subscriptionLists: string[]; webtrekk?: WebtrekkData; metaData?: MetaData[]; }; export type TrackingEventPayload = { webtrekk?: WebtrekkEventData; }; export type WebToUDPTrackingEventPayload = { actionName: string; actionSource?: string; actionType?: string; actionElement?: string; actionValue?: string; actionLocation?: string; itemUrn?: string; showName?: string; episodeName?: string; }; export type PlayVideoPayload = { // The URN of the video. urn: string; // Start time in seconds. startTime: number; // A URL where the given video can be played on the web. url: string; // Media title title: string; // Show title showTitle: string; // Duration in seconds duration: number; // Video image URL imageUrl?: string; // Video published date ISO8601 publishedDate: string; //The aspect ratio aspectRatio: AspectRatio; }; export type PlayAudioPayload = { // The URN of the audio. urn: string; // Start time in seconds. startTime: number; // An URL where the given audio can be played on the web. url: string; // Audio title title: string; // Show title showTitle: string; // Audio image URL imageUrl?: string; // Audio published date ISO8601 publishedDate: string; // Duration in seconds duration: number; }; export type PlayLivestreamPayload = { // The URN of the media. urn: string; // An URL where the given livestream can be played on the web. url: string; // Livestream title title: string; // Media image URL imageUrl?: string; // The media type. Either Audio, Video mediaType: MediaType; }; export type SetImageGalleryIndex = { // The id of the image gallery galleryId: string; // The 0-based index of the image which should be displayed in the image gallery index: number; }; export type WebtrekkData = { content_category_1?: string; content_category_2?: string; content_category_3?: string; content_category_4?: string; content_id?: number; content_layout_name?: string; content_page_elements?: string; content_page_type?: string; content_elapsed_since_publication?: string; content_publication_date?: string; content_publication_date_concatenated?: string; content_publication_datetime_concatenated?: string; content_publication_time?: string; content_publication_time_concatenated?: string; content_publication_version?: string; content_modification_datetime?: string; content_publication_datetime?: string; content_title?: string; content_title_pretty?: string; content_tags_subject?: string; navigation_content_filter?: string; navigation_environment?: string; navigation_property_type?: string; srg_mod1?: string; srg_mod2?: string; srg_mod3?: string; srg_mod4?: string; srg_referrer?: string; page_urn?: string; }; export type WebtrekkEventData = { event_source?: string; event_name?: string; event_value?: string; event_type?: string; }; export type MetaDataType = | 'portal' | 'theme' | 'subject' | 'level' | 'userNeed' | 'rubric'; export type MetaData = { urn: string; name: string; type: MetaDataType; }; export enum MediaType { Audio = 'AUDIO', Video = 'VIDEO', } export enum AspectRatio { R_1_1 = '1:1', R_4_5 = '4:5', R_4_3 = '4:3', R_9_16 = '9:16', R_16_9 = '16:9', } export enum PlaybackState { Playing = 'PLAYING', Stopped = 'STOPPED', } // inform the app about the current comments count and state export type CommentsInfoEvent = { eventType: 'CommentsInfo'; payload: CommentsInfoEventPayload; }; export type CommentsInfoEventPayload = { commentsPublished: number; threadState: ThreadState; }; export enum ThreadState { Open = 'open', Closed = 'closed', }