@memberjunction/react-runtime
Version:
Platform-agnostic React component runtime for MemberJunction. Provides core compilation, registry, and execution capabilities for React components in any JavaScript environment.
102 lines • 2.91 kB
TypeScript
import { ComponentLibraryEntity } from '@memberjunction/core-entities';
import { ComponentLibraryDependency, ComponentStyles, ComponentObject } from '@memberjunction/interactive-component-types';
export interface CompiledComponent {
factory: (context: RuntimeContext, styles?: ComponentStyles, components?: Record<string, any>) => ComponentObject;
id: string;
name: string;
compiledAt: Date;
warnings?: string[];
}
export interface CompileOptions {
componentName: string;
componentCode: string;
styles?: ComponentStyles;
production?: boolean;
babelPlugins?: string[];
babelPresets?: string[];
libraries?: ComponentLibraryDependency[];
dependencies?: Array<{
name: string;
code?: string;
}>;
allLibraries: ComponentLibraryEntity[];
}
export interface RegistryEntry {
component: ComponentObject;
metadata: ComponentMetadata;
lastAccessed: Date;
refCount: number;
}
export interface ComponentMetadata {
id: string;
name: string;
version: string;
namespace: string;
registeredAt: Date;
tags?: string[];
}
export interface ComponentError {
message: string;
stack?: string;
componentName: string;
phase: 'compilation' | 'registration' | 'render' | 'runtime';
details?: any;
}
export interface ComponentProps {
data: any;
userState: any;
utilities: any;
callbacks: any;
components?: Record<string, any>;
styles?: ComponentStyles;
onStateChanged?: (stateUpdate: Record<string, any>) => void;
}
export interface CompilerConfig {
babel: {
presets: string[];
plugins: string[];
};
minify: boolean;
sourceMaps: boolean;
cache: boolean;
maxCacheSize: number;
debug?: boolean;
}
export interface RegistryConfig {
maxComponents: number;
cleanupInterval: number;
useLRU: boolean;
enableNamespaces: boolean;
debug?: boolean;
}
export interface CompilationResult {
success: boolean;
component?: CompiledComponent;
error?: ComponentError;
duration: number;
size?: number;
loadedLibraries?: Map<string, any>;
}
export interface RuntimeContext {
React: any;
ReactDOM?: any;
libraries?: Record<string, any>;
utilities?: Record<string, any>;
}
export interface ComponentLifecycle {
beforeMount?: () => void;
afterMount?: () => void;
beforeUpdate?: (prevProps: any, nextProps: any) => void;
afterUpdate?: (prevProps: any, currentProps: any) => void;
beforeUnmount?: () => void;
}
export interface ErrorBoundaryOptions {
onError?: (error: Error, errorInfo: any) => void;
fallback?: any;
logErrors?: boolean;
recovery?: 'retry' | 'reset' | 'none';
}
export * from './library-config';
export * from './dependency-types';
export { ComponentObject } from '@memberjunction/interactive-component-types';
//# sourceMappingURL=index.d.ts.map