import { WEBVIEW_LOGGERS } from "src/electron-preload/webview/lib/const" ; import { curryFunctionMembers , getPlainErrorProps , testProtonCalendarAppPage } from "src/shared/util" ; import { documentCookiesForCustomScheme , getLocationHref } from "src/electron-preload/webview/lib/util" ; import { initProviderApi } from "./provider-api" ; import { registerApi } from "./api" ; import { setupProtonOpenNewTabEventHandler } from "src/electron-preload/webview/lib/custom-event" ; const logger = curryFunctionMembers ( WEBVIEW_LOGGERS . calendar , __filename ) ; const protonAppPageStatus = testProtonCalendarAppPage ( { url : getLocationHref ( ) , logger } ) ; window . addEventListener ( "error" , ( event ) => { const { message , filename , lineno , colno , error } = event ; if ( BUILD_ENVIRONMENT === "development" ) { console . log ( "window.error event:" , { message , filename , lineno , colno , error } ) ; return ; } logger . error ( { message , filename , lineno , colno , error : getPlainErrorProps ( error ) } ) ; event . preventDefault ( ) ; } ) ; documentCookiesForCustomScheme . enable ( logger ) ; setupProtonOpenNewTabEventHandler ( logger ) ; if ( protonAppPageStatus . shouldInitProviderApi ) { initProviderApi ( ) . then ( registerApi ) . catch ( ( error ) => { logger . error ( error ) ; throw error ; } ) ; }