({
startInLoadingState,
onNavigationStateChange,
onLoadStart,
onLoad,
onLoadProgress,
onLoadEnd,
onError,
onLoadSubResourceError,
onHttpErrorProp,
onMessageProp,
onOpenWindowProp,
onRenderProcessGoneProp,
onContentProcessDidTerminateProp,
originWhitelist,
onShouldStartLoadWithRequestProp,
onShouldStartLoadWithRequestCallback,
}: {
startInLoadingState?: boolean;
onNavigationStateChange?: (event: WebViewNavigation) => void;
onLoadStart?: (event: WebViewNavigationEvent) => void;
onLoad?: (event: WebViewNavigationEvent) => void;
onLoadProgress?: (event: WebViewProgressEvent) => void;
onLoadEnd?: (event: WebViewNavigationEvent | WebViewErrorEvent) => void;
onError?: (event: WebViewErrorEvent) => void;
onLoadSubResourceError?: (event: WebViewErrorEvent) => void;
onHttpErrorProp?: (event: WebViewHttpErrorEvent) => void;
onMessageProp?: (event: WebViewMessageEvent) => void;
onOpenWindowProp?: (event: WebViewOpenWindowEvent) => void;
onRenderProcessGoneProp?: (event: WebViewRenderProcessGoneEvent) => void;
onContentProcessDidTerminateProp?: (event: WebViewTerminatedEvent) => void;
originWhitelist: readonly string[];
onShouldStartLoadWithRequestProp?: OnShouldStartLoadWithRequest;
onShouldStartLoadWithRequestCallback: (
shouldStart: boolean,
url: string,
lockIdentifier?: number,
) => void;
})
| 91 | }; |
| 92 | |
| 93 | export const useWebViewLogic = ({ |
| 94 | startInLoadingState, |
| 95 | onNavigationStateChange, |
| 96 | onLoadStart, |
| 97 | onLoad, |
| 98 | onLoadProgress, |
| 99 | onLoadEnd, |
| 100 | onError, |
| 101 | onLoadSubResourceError, |
| 102 | onHttpErrorProp, |
| 103 | onMessageProp, |
| 104 | onOpenWindowProp, |
| 105 | onRenderProcessGoneProp, |
| 106 | onContentProcessDidTerminateProp, |
| 107 | originWhitelist, |
| 108 | onShouldStartLoadWithRequestProp, |
| 109 | onShouldStartLoadWithRequestCallback, |
| 110 | }: { |
| 111 | startInLoadingState?: boolean; |
| 112 | onNavigationStateChange?: (event: WebViewNavigation) => void; |
| 113 | onLoadStart?: (event: WebViewNavigationEvent) => void; |
| 114 | onLoad?: (event: WebViewNavigationEvent) => void; |
| 115 | onLoadProgress?: (event: WebViewProgressEvent) => void; |
| 116 | onLoadEnd?: (event: WebViewNavigationEvent | WebViewErrorEvent) => void; |
| 117 | onError?: (event: WebViewErrorEvent) => void; |
| 118 | onLoadSubResourceError?: (event: WebViewErrorEvent) => void; |
| 119 | onHttpErrorProp?: (event: WebViewHttpErrorEvent) => void; |
| 120 | onMessageProp?: (event: WebViewMessageEvent) => void; |
| 121 | onOpenWindowProp?: (event: WebViewOpenWindowEvent) => void; |
| 122 | onRenderProcessGoneProp?: (event: WebViewRenderProcessGoneEvent) => void; |
| 123 | onContentProcessDidTerminateProp?: (event: WebViewTerminatedEvent) => void; |
| 124 | originWhitelist: readonly string[]; |
| 125 | onShouldStartLoadWithRequestProp?: OnShouldStartLoadWithRequest; |
| 126 | onShouldStartLoadWithRequestCallback: ( |
| 127 | shouldStart: boolean, |
| 128 | url: string, |
| 129 | lockIdentifier?: number, |
| 130 | ) => void; |
| 131 | }) => { |
| 132 | const [viewState, setViewState] = useState<'IDLE' | 'LOADING' | 'ERROR'>( |
| 133 | startInLoadingState ? 'LOADING' : 'IDLE', |
| 134 | ); |
| 135 | const [lastErrorEvent, setLastErrorEvent] = useState<WebViewError | null>(null); |
| 136 | const startUrl = useRef<string | null>(null); |
| 137 | |
| 138 | const updateNavigationState = useCallback( |
| 139 | (event: WebViewNavigationEvent) => { |
| 140 | onNavigationStateChange?.(event.nativeEvent); |
| 141 | }, |
| 142 | [onNavigationStateChange], |
| 143 | ); |
| 144 | |
| 145 | const onLoadingStart = useCallback( |
| 146 | (event: WebViewNavigationEvent) => { |
| 147 | // Needed for android |
| 148 | startUrl.current = event.nativeEvent.url; |
| 149 | // !Needed for android |
| 150 |
no test coverage detected
searching dependent graphs…