// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import type {NativeSyntheticEvent, ViewProps} from 'react-native'; import type {DirectEventHandler, Double, Int32} from 'react-native/Libraries/Types/CodegenTypes'; // Event payload interfaces matching native implementation export type OnLinkPressedPayload = Readonly<{ url: string; }>; export type OnLoadErrorPayload = Readonly<{ message: string; }>; export type OnPasswordFailedPayload = Readonly<{ remainingAttempts: Int32; }>; export type OnPasswordRequiredPayload = Readonly<{ maxAttempts: Int32; remainingAttempts: Int32; }>; export type OnPasswordLimitReachedPayload = Readonly<{ maxAttempts: Int32; }>; export type OnTapPayload = Readonly<{ x: Double; y: Double; }>; // Legacy event types for old architecture compatibility 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?: DirectEventHandler; onLinkPressedDisabled?: DirectEventHandler<{}>; onLoad?: DirectEventHandler<{}>; onPasswordRequired?: DirectEventHandler; onPasswordFailed?: DirectEventHandler; onPasswordFailureLimitReached?: DirectEventHandler; onLoadError?: DirectEventHandler; onTap?: DirectEventHandler; } // For codegen to work properly, we need to export the codegenNativeComponent call directly // This works with both Old and New Architecture: // - New Arch (Fabric): Uses the codegen-generated component // - Old Arch (Paper): Falls back to requireNativeComponent at runtime export default codegenNativeComponent('SecurePdfViewer', { excludedPlatforms: [], paperComponentName: 'SecurePdfViewer', });