// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {requireNativeComponent, type HostComponent, type NativeSyntheticEvent, type ViewProps} from 'react-native'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; interface OnLinkPressedPayload { url: string; } interface OnLoadErrorPayload { message: string; } interface OnPasswordFailedPayload { remainingAttempts: number; } interface OnPasswordRequiredPayload { maxAttempts: number; remainingAttempts: number; } interface OnPasswordLimitReached { maxAttempts: number; } interface OnTapPayload { x: number; y: number; pageX: number; pageY: number; timestamp: number; pointerType: 'touch' | 'mouse' | 'pen'; } export type OnLinkPressedEvent = NativeSyntheticEvent; export type OnLoadErrorEvent = NativeSyntheticEvent; export type OnPasswordFailedEvent = NativeSyntheticEvent; export type OnPasswordLimitReachedEvent = NativeSyntheticEvent; export type OnPasswordRequiredEvent = NativeSyntheticEvent; export type OnTapEvent = NativeSyntheticEvent; export interface NativeProps extends ViewProps { source: string; password?: string; allowLinks?: boolean; onLinkPressed?: (event: OnLinkPressedEvent) => void; onLinkPressedDisabled?: () => void; onLoad?: () => void; onPasswordRequired?: (event: OnPasswordRequiredEvent) => void; onPasswordFailed?: (event: OnPasswordFailedEvent) => void; onPasswordFailureLimitReached?: (event: OnPasswordLimitReachedEvent) => void; onLoadError?: (event: OnLoadErrorEvent) => void; onTap?: (event: OnTapEvent) => void; } const COMPONENT_NAME = 'SecurePdfViewer'; let SecurePdfViewerNativeComponent: HostComponent; // @ts-expect-error global not defined if (global?.nativeFabricUIManager == null) { // Paper (Old Architecture) SecurePdfViewerNativeComponent = requireNativeComponent(COMPONENT_NAME); } else { // Fabric (New Architecture) SecurePdfViewerNativeComponent = codegenNativeComponent(COMPONENT_NAME); } export default SecurePdfViewerNativeComponent;