Deprecated compatibility wrapper that provides backward compatibility for applications migrating from legacy Unimodules infrastructure to Expo Modules API
npx @tessl/cli install tessl/npm-unimodules--core@7.2.0@unimodules/core is a deprecated compatibility wrapper that provides backward compatibility for applications migrating from the legacy Unimodules infrastructure to the newer Expo Modules API. It serves as a bridge between old @unimodules/core architecture and modern expo-modules-core system, allowing existing React Native applications to continue functioning during migration.
⚠️ Deprecation Notice: This package is deprecated in favor of the expo package. Applications should migrate using the guide at https://expo.fyi/expo-modules-migration
npm install @unimodules/coreimport {
EventEmitter,
NativeModulesProxy,
Platform,
requireNativeViewManager,
CodedError,
UnavailabilityError,
DeviceEventEmitter,
Subscription,
SyntheticPlatformEmitter,
ProxyNativeModule,
deprecate,
// Permission system
PermissionStatus,
PermissionResponse,
createPermissionHook
} from "@unimodules/core";For CommonJS:
const {
EventEmitter,
NativeModulesProxy,
Platform,
requireNativeViewManager,
CodedError,
UnavailabilityError,
DeviceEventEmitter,
Subscription,
SyntheticPlatformEmitter,
ProxyNativeModule,
deprecate,
PermissionStatus,
PermissionResponse,
createPermissionHook
} = require("@unimodules/core");import {
EventEmitter,
NativeModulesProxy,
Platform,
CodedError
} from "@unimodules/core";
// Platform detection
if (Platform.OS === 'ios') {
console.log('Running on iOS');
}
// Access native modules
const MyNativeModule = NativeModulesProxy.MyModule;
if (MyNativeModule) {
await MyNativeModule.someMethod();
}
// Event handling
const eventEmitter = new EventEmitter(MyNativeModule);
const subscription = eventEmitter.addListener('eventName', (data) => {
console.log('Received event:', data);
});
// Clean up
subscription.remove();@unimodules/core provides essential infrastructure for React Native/Expo module development:
NativeModulesProxy provides dynamic access to native modulesEventEmitter handles native-to-JavaScript event communicationrequireNativeViewManager for native UI componentsCore event handling system for native module events with automatic listener lifecycle management.
class EventEmitter {
constructor(nativeModule: NativeModule);
addListener<T>(eventName: string, listener: (event: T) => void): Subscription;
removeAllListeners(eventName: string): void;
removeSubscription(subscription: Subscription): void;
emit(eventName: string, ...params: any[]): void;
}
interface Subscription {
remove: () => void;
}Proxy system providing dynamic access to native modules with automatic method binding and error handling.
const NativeModulesProxy: { [moduleName: string]: ProxyNativeModule };
interface ProxyNativeModule {
[propertyName: string]: any;
addListener: (eventName: string) => void;
removeListeners: (count: number) => void;
}Extended platform detection and capability checking beyond React Native's built-in Platform.
interface PlatformInterface {
OS: PlatformOSType;
select: <T>(specifics: { [platform in PlatformSelectOSType]?: T }) => T;
isDOMAvailable: boolean;
canUseEventListeners: boolean;
canUseViewport: boolean;
isAsyncDebugging: boolean;
}
const Platform: PlatformInterface;Standardized error classes for consistent error handling across Expo modules.
class CodedError extends Error {
code: string;
info?: any;
constructor(code: string, message: string);
}
class UnavailabilityError extends CodedError {
constructor(moduleName: string, propertyName: string);
}Complete permission system with React hooks for managing app permissions.
enum PermissionStatus {
GRANTED = 'granted',
UNDETERMINED = 'undetermined',
DENIED = 'denied'
}
interface PermissionResponse {
status: PermissionStatus;
expires: PermissionExpiration;
granted: boolean;
canAskAgain: boolean;
}
function createPermissionHook<Permission extends PermissionResponse, Options extends object>(
methods: PermissionHookMethods<Permission, Options>
): (options?: PermissionHookOptions<Options>) => [Permission | null, () => Promise<Permission>, () => Promise<Permission>];Component creation utilities for integrating native UI components into React Native applications.
function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P>;API deprecation utilities and additional event emitters for platform-specific functionality.
function deprecate(
library: string,
deprecatedAPI: string,
options?: {
replacement?: string;
currentVersion?: string;
versionToRemove?: string;
}
): void;
const SyntheticPlatformEmitter: EventEmitter;
const DeviceEventEmitter: DeviceEventEmitterStatic;
const RCTDeviceEventEmitter: DeviceEventEmitterStatic; // @deprecated Use DeviceEventEmittertype PlatformOSType = 'ios' | 'android' | 'windows' | 'macos' | 'web';
type PlatformSelectOSType = PlatformOSType | 'native' | 'electron' | 'default';
type PlatformSelect = <T>(specifics: { [platform in PlatformSelectOSType]?: T }) => T;
type PermissionExpiration = 'never' | number;
interface NativeModule {
startObserving?: () => void;
stopObserving?: () => void;
addListener: (eventName: string) => void;
removeListeners: (count: number) => void;
}
interface Subscription {
remove: () => void;
}
interface ProxyNativeModule {
[propertyName: string]: any;
addListener: (eventName: string) => void;
removeListeners: (count: number) => void;
}
interface DeviceEventEmitterStatic {
addListener: (eventType: string, listener: (data: any) => void) => { remove: () => void };
emit: (eventType: string, ...args: any[]) => void;
removeAllListeners: (eventType: string) => void;
}