react-native-flix-codepush
Version:
A modern CodePush implementation for React Native applications
85 lines (75 loc) • 2.49 kB
text/typescript
import type { CodePushHandlerProps } from './components/CodePushHandler';
import { CodePushHandler } from './components/CodePushHandler';
import type { DownloadProgressViewProps } from './components/DownloadProgressView';
import { DownloadProgressView } from './components/DownloadProgressView';
import type { UpdateDialogProps } from './components/UpdateDialog';
import { UpdateDialog } from './components/UpdateDialog';
import { useCodePush } from './hooks/useCodePush';
import type { CodePushInstallMode } from './types';
import { codePush, LegacyCodePush } from './utils/LegacySupport';
// Export types
export * from './types';
export type { CodePushHandlerProps, DownloadProgressViewProps, UpdateDialogProps };
// Export core functionality
export { ApiClient } from './core/ApiClient';
export { CodePush } from './core/CodePush';
export { PackageManager } from './core/PackageManager';
export { UpdateManager } from './core/UpdateManager';
// Export hooks
export { useCodePush } from './hooks/useCodePush';
// Export components
export { CodePushHandler } from './components/CodePushHandler';
export { DownloadProgressView } from './components/DownloadProgressView';
export { UpdateDialog } from './components/UpdateDialog';
// Export utilities
export { CodePushError } from './utils/CodePushError';
// Export legacy support
export { codePush, LegacyCodePush };
/**
* Configure the CodePush SDK with the provided options
*/
export function configureCodePush(_config: {
deploymentKey: string;
serverUrl: string;
checkFrequency?: number;
installMode?: string;
mandatoryInstallMode?: string;
minimumBackgroundDuration?: number;
}) {
return {
useCodePush,
CodePushHandler,
UpdateDialog,
DownloadProgressView,
codePush,
...LegacyCodePush,
};
}
/**
* Create a custom hook with pre-configured options
*/
export function createCodePushHook(options: {
deploymentKey: string;
installMode?: string;
mandatoryInstallMode?: string;
minimumBackgroundDuration?: number;
}) {
return function useConfiguredCodePush() {
return useCodePush({
...options,
installMode: options.installMode as CodePushInstallMode,
mandatoryInstallMode: options.mandatoryInstallMode as CodePushInstallMode,
});
};
}
// Export default for backward compatibility
export default {
...LegacyCodePush,
configureCodePush,
createCodePushHook,
useCodePush,
CodePushHandler,
UpdateDialog,
DownloadProgressView,
codePush,
};