js-use-core
Version:
JavaScript Comprehensive tool library, including full screen, copy and paste functions
1,429 lines (1,397 loc) • 51.6 kB
TypeScript
interface BaseOptions$1 {
debug?: boolean;
timeout?: number;
retries?: number;
cache?: boolean;
cacheTTL?: number;
}
declare enum ModuleState {
UNINITIALIZED = "uninitialized",
INITIALIZING = "initializing",
INITIALIZED = "initialized",
RUNNING = "running",
PAUSED = "paused",
ERROR = "error",
DESTROYED = "destroyed"
}
declare enum LogLevel$1 {
DEBUG = 0,
INFO = 1,
WARN = 2,
ERROR = 3,
SILENT = 4
}
declare enum AsyncOperationStatus {
PENDING = "pending",
RUNNING = "running",
COMPLETED = "completed",
FAILED = "failed",
CANCELLED = "cancelled"
}
interface BrowserInfo$1 {
readonly name: 'Chrome' | 'Edge' | 'Firefox' | 'Safari' | 'Opera' | 'IE' | 'Samsung' | string;
readonly version: string;
readonly major: number;
readonly minor: number;
readonly patch: number;
readonly channel?: 'stable' | 'beta' | 'dev' | 'canary' | 'nightly';
}
interface EngineInfo {
readonly name: 'Blink' | 'WebKit' | 'Gecko' | 'Trident' | 'Presto' | string;
readonly version: string;
}
interface OSInfo {
readonly name: 'Windows' | 'macOS' | 'iOS' | 'Android' | 'Linux' | 'HarmonyOS' | string;
readonly version: string;
}
interface UADeviceInfo {
readonly type: 'desktop' | 'mobile' | 'tablet' | 'tv' | 'wearable';
readonly vendor?: string;
readonly model?: string;
}
interface CPUInfo {
readonly architecture: 'amd64' | 'arm64' | 'arm' | 'ia32' | 'loongarch64' | 'riscv64' | string;
}
interface ParsedUA {
readonly browser: BrowserInfo$1;
readonly engine: EngineInfo;
readonly os: OSInfo;
readonly device: UADeviceInfo;
readonly cpu: CPUInfo;
readonly isBot: boolean;
readonly isWebView: boolean;
readonly isHeadless: boolean;
readonly source: string;
}
interface UAParserPlugin {
test: (ua: string) => boolean;
parse: (ua: string) => Partial<ParsedUA>;
}
interface ModernBrowserOptions {
es2020?: boolean;
webgl2?: boolean;
webassembly?: boolean;
serviceWorker?: boolean;
}
interface UAGenerateSpec {
browser?: Partial<BrowserInfo$1>;
engine?: Partial<EngineInfo>;
os?: Partial<OSInfo>;
device?: Partial<UADeviceInfo>;
cpu?: Partial<CPUInfo>;
}
interface UAManagerOptions extends BaseOptions$1 {
enablePlugins?: boolean;
maxCacheSize?: number;
parseTimeout?: number;
}
declare function parseUA(ua?: string): ParsedUA;
declare function generateUA(spec: UAGenerateSpec): string;
declare enum ComparisonResult {
LESS_THAN = -1,
EQUAL = 0,
GREATER_THAN = 1
}
declare function compareVersions(version1: string, version2: string): ComparisonResult;
declare enum ErrorType$1 {
USER_ERROR = "USER_ERROR",
SYSTEM_ERROR = "SYSTEM_ERROR",
NETWORK_ERROR = "NETWORK_ERROR",
PERMISSION_ERROR = "PERMISSION_ERROR",
CONFIG_ERROR = "CONFIG_ERROR",
VALIDATION_ERROR = "VALIDATION_ERROR",
TIMEOUT_ERROR = "TIMEOUT_ERROR",
UNSUPPORTED_ERROR = "UNSUPPORTED_ERROR",
INTERNAL_ERROR = "INTERNAL_ERROR",
EXTERNAL_ERROR = "EXTERNAL_ERROR",
UNKNOWN_ERROR = "UNKNOWN_ERROR"
}
declare enum ErrorSeverity {
LOW = "low",
MEDIUM = "medium",
HIGH = "high",
CRITICAL = "critical"
}
interface ErrorContext$1 {
module: string;
method: string;
input?: any;
userAgent?: string;
timestamp: number;
requestId?: string;
userId?: string;
sessionId?: string;
url?: string;
stackTrace?: string;
extra?: Record<string, any>;
}
interface ErrorSolution {
description: string;
steps: string[];
links?: string[];
automatic?: boolean;
priority?: number;
}
interface ProcessedError$1 {
type: ErrorType$1;
severity: ErrorSeverity;
message: string;
userMessage: string;
originalError: Error;
context: ErrorContext$1;
code: string;
recoverable: boolean;
solutions: ErrorSolution[];
id: string;
processedAt: number;
relatedErrors?: string[];
}
interface BaseOptions {
debug?: boolean;
timeout?: number;
retries?: number;
cache?: boolean;
}
declare enum ErrorType {
USER_ERROR = "USER_ERROR",
SYSTEM_ERROR = "SYSTEM_ERROR",
NETWORK_ERROR = "NETWORK_ERROR",
PERMISSION_ERROR = "PERMISSION_ERROR",
CONFIG_ERROR = "CONFIG_ERROR",
TIMEOUT_ERROR = "TIMEOUT_ERROR",
VALIDATION_ERROR = "VALIDATION_ERROR",
INTERNAL_ERROR = "INTERNAL_ERROR",
UNKNOWN_ERROR = "UNKNOWN_ERROR"
}
interface ErrorContext {
module: string;
method: string;
input?: any;
userAgent?: string;
timestamp: number;
extra?: Record<string, any>;
}
interface ProcessedError {
type: ErrorType;
message: string;
originalError: Error;
context: ErrorContext;
solution?: string;
recoverable: boolean;
code?: string;
}
declare enum LogLevel {
DEBUG = 0,
INFO = 1,
WARN = 2,
ERROR = 3
}
interface LogEntry {
level: LogLevel;
message: string;
timestamp: number;
module?: string;
data?: any;
}
interface CacheEntry<T = any> {
value: T;
expireAt: number;
createdAt: number;
accessCount: number;
lastAccessed: number;
}
interface CacheConfig {
maxSize?: number;
defaultTTL?: number;
enableLRU?: boolean;
cleanupInterval?: number;
}
type EventListener$1 = (...args: any[]) => void;
interface EventListenerConfig {
listener: EventListener$1;
once?: boolean;
priority?: number;
}
interface ApiResponse<T = any> {
success: boolean;
data?: T;
error?: ProcessedError;
metadata?: {
timestamp: number;
version: string;
cached: boolean;
};
}
declare class EventEmitter {
private events;
private maxListeners;
on(event: string, listener: EventListener$1, options?: {
once?: boolean;
priority?: number;
}): this;
once(event: string, listener: EventListener$1, priority?: number): this;
off(event: string, listener?: EventListener$1): this;
emit(event: string, ...args: any[]): boolean;
listenerCount(event: string): number;
listeners(event: string): EventListener$1[];
eventNames(): string[];
removeAllListeners(event?: string): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
prependListener(event: string, listener: EventListener$1): this;
prependOnceListener(event: string, listener: EventListener$1): this;
}
declare class Logger {
private level;
private module;
private logs;
private maxLogs;
private enableConsole;
constructor(module?: string, options?: {
level?: LogLevel;
maxLogs?: number;
enableConsole?: boolean;
});
setLevel(level: LogLevel): void;
getLevel(): LogLevel;
debug(message: string, data?: any): void;
info(message: string, data?: any): void;
warn(message: string, data?: any): void;
error(message: string, data?: any): void;
private log;
private outputToConsole;
getLogs(): LogEntry[];
getLogsByLevel(level: LogLevel): LogEntry[];
getLogsByTimeRange(startTime: number, endTime: number): LogEntry[];
clear(): void;
setMaxLogs(maxLogs: number): void;
setConsoleOutput(enable: boolean): void;
exportLogs(): string;
importLogs(jsonString: string): void;
createChild(subModule: string): Logger;
}
declare class CustomError extends Error {
readonly type: ErrorType$1;
readonly code?: string;
readonly context?: ErrorContext$1;
readonly recoverable: boolean;
constructor(type: ErrorType$1, message: string, options?: {
code?: string;
context?: ErrorContext$1;
recoverable?: boolean;
cause?: Error;
});
}
declare class ErrorHandler {
private logger;
private errorSolutions;
constructor(logger?: Logger);
handleError(error: Error, context?: Partial<ErrorContext$1>): ProcessedError$1;
createError(type: ErrorType$1, message: string, details?: {
code?: string;
context?: Partial<ErrorContext$1>;
recoverable?: boolean;
cause?: Error;
}): CustomError;
isRecoverableError(error: Error): boolean;
getErrorSolution(error: Error): string | null;
getErrorSolutions(error: Error): Array<{
description: string;
steps: string[];
links?: string[];
automatic?: boolean;
priority?: number;
}>;
private getErrorSeverity;
private generateErrorCode;
private generateErrorId;
addErrorSolution(errorCode: string, solution: string): void;
addErrorSolutions(solutions: Record<string, string>): void;
private classifyError;
private getUserFriendlyMessage;
private getErrorCode;
private getDefaultSolution;
private initializeErrorSolutions;
}
declare class Cache<T = any> {
private cache;
private config;
private cleanupTimer?;
constructor(config?: CacheConfig);
set(key: string, value: T, ttl?: number): void;
get(key: string): T | undefined;
has(key: string): boolean;
delete(key: string): boolean;
clear(): void;
size(): number;
keys(): string[];
getInfo(key: string): CacheEntry<T> | undefined;
touch(key: string, ttl?: number): boolean;
getOrSet(key: string, factory: () => T | Promise<T>, ttl?: number): Promise<T>;
mset(entries: Array<[string, T]>, ttl?: number): void;
mget(keys: string[]): Array<T | undefined>;
mdel(keys: string[]): number;
getStats(): {
size: number;
maxSize: number;
hitRate: number;
totalAccess: number;
expiredCount: number;
};
cleanup(): number;
private evictLRU;
private startCleanup;
stopCleanup(): void;
updateConfig(config: Partial<CacheConfig>): void;
destroy(): void;
}
declare abstract class BaseManager<T extends BaseOptions$1 = BaseOptions$1> {
protected options: Required<T>;
protected eventEmitter: EventEmitter;
protected errorHandler: ErrorHandler;
protected logger: Logger;
protected cache?: Cache;
protected initialized: boolean;
protected destroyed: boolean;
private initPromise?;
private initializing;
constructor(options?: T, moduleName?: string);
abstract initialize(): Promise<void>;
abstract destroy(): void;
protected abstract getDefaultOptions(): Required<T>;
on(event: string, listener: (...args: any[]) => void, options?: {
once?: boolean;
priority?: number;
}): this;
off(event: string, listener?: (...args: any[]) => void): this;
emit(event: string, ...args: any[]): boolean;
once(event: string, listener: (...args: any[]) => void, priority?: number): this;
listenerCount(event: string): number;
eventNames(): string[];
protected handleError(error: Error, context?: string): ProcessedError$1;
protected validateInput(input: any, schema: any): boolean;
protected safeExecute<R>(operation: () => Promise<R>, context: string, retries?: number): Promise<R>;
protected getCached<R>(key: string): R | undefined;
protected setCached<R>(key: string, value: R, ttl?: number): void;
protected getOrSetCached<R>(key: string, factory: () => Promise<R>, ttl?: number): Promise<R>;
protected ensureInitialized(): Promise<void>;
protected ensureInitializedSync(): void;
protected ensureNotDestroyed(): void;
ready(): Promise<void>;
getStatus(): {
initialized: boolean;
destroyed: boolean;
eventListeners: number;
cacheSize?: number;
initializing: boolean;
};
updateOptions(newOptions: Partial<T>): void;
private mergeDefaultOptions;
private setupErrorHandling;
private startAutoInitialization;
protected baseDestroy(): void;
}
declare class UAManager extends BaseManager<UAManagerOptions> {
private plugins;
private parseStats;
constructor(options?: UAManagerOptions);
protected getDefaultOptions(): Required<UAManagerOptions>;
initialize(): Promise<void>;
destroy(): void;
parse(ua?: string): Promise<Readonly<ParsedUA>>;
parseSync(ua?: string): Readonly<ParsedUA>;
stringify(spec: UAGenerateSpec): string;
satisfies(ua: ParsedUA | string, range: string): boolean;
isModern(ua: ParsedUA, opts?: ModernBrowserOptions): boolean;
getCurrent(): Promise<ParsedUA>;
use(plugin: UAParserPlugin): void;
removePlugin(plugin: UAParserPlugin): boolean;
getStats(): {
totalParses: number;
cacheHits: number;
pluginHits: number;
errors: number;
cacheHitRate: number;
pluginCount: number;
cacheSize?: number;
};
resetStats(): void;
getCurrentUA(): string;
private performParse;
private performParseSync;
private freezeParseResult;
clearCache(): void;
getCacheSize(): number;
}
declare class UA {
private static getManager;
static parse(ua?: string): Readonly<ParsedUA>;
static parseAsync(ua?: string): Promise<Readonly<ParsedUA>>;
static stringify(spec: UAGenerateSpec): string;
static satisfies(ua: ParsedUA | string, range: string): boolean;
static isModern(ua: ParsedUA, opts?: ModernBrowserOptions): boolean;
static get current(): ParsedUA;
static use(plugin: UAParserPlugin): void;
static clearCache(): void;
static getCacheSize(): number;
static getStats(): {
totalParses: number;
cacheHits: number;
pluginHits: number;
errors: number;
cacheHitRate: number;
pluginCount: number;
cacheSize?: number;
};
static getCurrentUA(): string;
static resetManager(): void;
}
declare function getCurrentUA(): Readonly<ParsedUA>;
declare function parseUserAgent(ua: string): Readonly<ParsedUA>;
declare function isCompatible(range: string, ua?: string): boolean;
declare const _default$2: {
UA: typeof UA;
getCurrentUA: typeof getCurrentUA;
parseUserAgent: typeof parseUserAgent;
isCompatible: typeof isCompatible;
};
interface MobileDetectOptions {
ua?: string | {
headers: {
'user-agent': string;
};
};
tablet?: boolean;
featureDetect?: boolean;
}
interface DeviceDetectorOptions extends MobileDetectOptions {
debug?: boolean;
timeout?: number;
retries?: number;
cache?: boolean;
cacheTTL?: number;
enablePerformanceMonitoring?: boolean;
}
declare enum DeviceType$1 {
MOBILE = "mobile",
TABLET = "tablet",
DESKTOP = "desktop"
}
declare enum OSType$1 {
WINDOWS = "windows",
MACOS = "macos",
LINUX = "linux",
ANDROID = "android",
IOS = "ios",
UNKNOWN = "unknown"
}
declare enum BrowserType$1 {
CHROME = "chrome",
FIREFOX = "firefox",
SAFARI = "safari",
EDGE = "edge",
IE = "ie",
OPERA = "opera",
UNKNOWN = "unknown"
}
interface DeviceInfo {
type: DeviceType$1;
os: OSType$1;
browser: BrowserType$1;
isMobile: boolean;
isTablet: boolean;
isDesktop: boolean;
isTouchDevice: boolean;
userAgent: string;
screen: {
width: number;
height: number;
pixelRatio: number;
};
}
interface DevicePerformanceInfo {
level: 'low' | 'medium' | 'high' | 'unknown';
score: number;
memory: number;
cores: number;
gpu: {
vendor: string;
renderer: string;
} | null;
}
declare function isMobile(opts?: MobileDetectOptions): boolean;
declare function isTablet(opts?: Omit<MobileDetectOptions, 'tablet'>): boolean;
declare function isDesktop(opts?: MobileDetectOptions): boolean;
declare function isTouchDevice(): boolean;
declare function isRetinaDisplay(): boolean;
declare function getDevicePerformanceInfo(): DevicePerformanceInfo;
declare function getPerformanceOptimizationSuggestions(): {
level: 'low' | 'medium' | 'high';
suggestions: string[];
settings: {
enableAnimations: boolean;
enableShadows: boolean;
enableBlur: boolean;
maxImageQuality: number;
enableLazyLoading: boolean;
};
};
declare class DeviceDetector extends BaseManager<DeviceDetectorOptions> {
private _deviceInfo;
private _detectionOptions;
constructor(options?: DeviceDetectorOptions);
protected getDefaultOptions(): Required<DeviceDetectorOptions>;
initialize(): Promise<void>;
destroy(): void;
getDeviceInfo(): Promise<DeviceInfo>;
refresh(): Promise<DeviceInfo>;
private _detectDevice;
private _getUserAgent;
setDetectionOptions(options: Partial<MobileDetectOptions>): this;
getDetectionOptions(): MobileDetectOptions;
checkDeviceType(type: 'mobile' | 'tablet' | 'desktop'): Promise<boolean>;
checkOS(os: string): Promise<boolean>;
checkBrowser(browser: string): Promise<boolean>;
getDeviceCapabilities(): Promise<{
touchSupport: boolean;
screenSize: {
width: number;
height: number;
pixelRatio: number;
};
userAgent: string;
online: boolean;
}>;
}
declare function getDeviceInfo(options?: DeviceDetectorOptions): Promise<DeviceInfo>;
declare function getDeviceInfoSync(options?: MobileDetectOptions): DeviceInfo;
declare function createDeviceDetector(options?: DeviceDetectorOptions): DeviceDetector;
declare function isDeviceType(type: 'mobile' | 'tablet' | 'desktop', options?: MobileDetectOptions): boolean;
declare const _default$1: {
DeviceDetector: typeof DeviceDetector;
getDeviceInfo: typeof getDeviceInfo;
getDeviceInfoSync: typeof getDeviceInfoSync;
createDeviceDetector: typeof createDeviceDetector;
isDeviceType: typeof isDeviceType;
};
type ClipboardDataType$1 = 'text' | 'html' | 'image' | 'rtf' | 'files';
interface ClipboardData {
type: ClipboardDataType$1;
data: string | Blob | File[] | ArrayBuffer;
size?: number;
timestamp?: number;
mimeType?: string;
encoding?: string;
}
interface CopyOptions {
format?: ClipboardDataType$1;
fallback?: boolean;
timeout?: number;
validateData?: boolean;
mimeType?: string;
encoding?: string;
preserveFormatting?: boolean;
sanitizeHtml?: boolean;
}
interface PasteOptions {
format?: ClipboardDataType$1;
fallback?: boolean;
timeout?: number;
maxSize?: number;
acceptedTypes?: string[];
sanitizeHtml?: boolean;
preserveFormatting?: boolean;
}
interface ClipboardManagerOptions extends BaseOptions$1 {
defaultFormat?: ClipboardDataType$1;
enablePermissionCheck?: boolean;
maxDataSize?: number;
enableDataValidation?: boolean;
enableFallback?: boolean;
permissionTimeout?: number;
enableHtmlSanitization?: boolean;
supportedMimeTypes?: string[];
autoRequestPermissions?: boolean;
fallbackStrategies?: ('modern' | 'execCommand' | 'selection' | 'input')[];
enableDataConversion?: boolean;
maxFileCount?: number;
allowedFileTypes?: string[];
}
declare enum ClipboardPermissionState {
GRANTED = "granted",
DENIED = "denied",
PROMPT = "prompt",
UNKNOWN = "unknown"
}
interface DataConverter {
readonly fromType: ClipboardDataType$1;
readonly toType: ClipboardDataType$1;
readonly name: string;
readonly supportsBigData?: boolean;
canConvert(from: ClipboardDataType$1, to: ClipboardDataType$1): boolean;
convert(data: any, from: ClipboardDataType$1, to: ClipboardDataType$1): Promise<any>;
validateInput?(data: any): boolean;
getOptions?(): Record<string, any>;
}
interface DataValidationRule {
name: string;
validate: (data: any, type: ClipboardDataType$1) => boolean | string;
required?: boolean;
errorMessage?: string;
}
interface DataValidationResult {
valid: boolean;
errors: string[];
warnings: string[];
processedData?: any;
}
interface DataProcessingOptions {
enableCompression?: boolean;
compressionThreshold?: number;
enableChunking?: boolean;
chunkSize?: number;
enableCaching?: boolean;
cacheExpiry?: number;
maxProcessingTime?: number;
}
declare class ClipboardManager extends BaseManager<ClipboardManagerOptions> {
private dataConverters;
private permissionCache;
private eventListeners;
constructor(options?: ClipboardManagerOptions);
protected getDefaultOptions(): Required<ClipboardManagerOptions>;
initialize(): Promise<void>;
destroy(): void;
get isSupported(): boolean;
get canRead(): boolean;
get canWrite(): boolean;
copyText(text: string, options?: CopyOptions): Promise<boolean>;
copyHTML(html: string, options?: CopyOptions): Promise<boolean>;
copyElement(element: Element | string, options?: CopyOptions): Promise<boolean>;
readText(options?: PasteOptions): Promise<string>;
readHTML(options?: PasteOptions): Promise<string>;
copyFiles(files: File[], options?: CopyOptions): Promise<boolean>;
readFiles(options?: PasteOptions): Promise<File[]>;
read(options?: PasteOptions): Promise<ClipboardData>;
private getFileExtension;
private checkBrowserSupport;
private checkPermissions;
private checkWritePermission;
private checkReadPermission;
private requestPermissionSmart;
private initializeDataConverters;
private registerDataConverter;
private initializeValidationRules;
private convertData;
private isLargeData;
private validateClipboardData;
private performBuiltInValidation;
private triggerWritePermissionRequest;
private triggerReadPermissionRequest;
private getPermissionErrorMessage;
private validateHtmlSafety;
private sanitizeHtml;
private isFileTypeAllowed;
private hashString;
private setupEventListeners;
private removeEventListeners;
private handleCopyEvent;
private handlePasteEvent;
private fallbackCopyText;
private executeFallbackStrategy;
private execCommandFallback;
private selectionApiFallback;
private inputElementFallback;
private textareaElementFallback;
private fallbackCopyHTML;
private executeHtmlFallbackStrategy;
private selectionHtmlFallback;
private execCommandHtmlFallback;
private fallbackCopyElement;
private fallbackRead;
onCopy(callback: (data: ClipboardData) => void): void;
onRead(callback: (data: ClipboardData) => void): void;
onSystemCopy(callback: (event: ClipboardEvent) => void): void;
onSystemPaste(callback: (event: ClipboardEvent) => void): void;
onPaste(callback: (data: ClipboardData) => void): void;
getPermissionStatus(): Promise<{
write: ClipboardPermissionState;
read: ClipboardPermissionState;
}>;
requestPermissions(): Promise<boolean>;
clear(): Promise<boolean>;
addValidationRule(type: ClipboardDataType$1, rule: DataValidationRule): void;
addDataConverter(converter: DataConverter): void;
detectDataType(data: any): ClipboardDataType$1;
validateData(data: any, type: ClipboardDataType$1, options?: {
strict?: boolean;
}): DataValidationResult;
convertDataFormat(data: any, from: ClipboardDataType$1, to: ClipboardDataType$1, options?: DataProcessingOptions): Promise<any>;
getProcessingStats(): {
converters: number;
validationRules: number;
cacheSize: number;
};
}
declare const clipboard: ClipboardManager;
interface FullscreenOptions extends BaseOptions {
navigationUI?: 'auto' | 'hide' | 'show';
enablePerformanceMonitoring?: boolean;
requestTimeout?: number;
allowKeyboardInput?: boolean;
}
type FullscreenEventType = 'change' | 'error' | 'request' | 'exit';
interface FullscreenState {
isFullscreen: boolean;
element: Element | null;
startTime?: number;
duration?: number;
}
interface FullscreenPerformanceMetrics {
enterTime: number;
exitTime: number;
duration: number;
errorCount: number;
successCount: number;
}
declare class FullscreenManager extends BaseManager<FullscreenOptions> {
private browserAdapter;
private removeChangeListener?;
private removeErrorListener?;
private currentState;
private performanceMetrics;
private requestStartTime;
constructor(options?: FullscreenOptions);
protected getDefaultOptions(): Required<FullscreenOptions>;
initialize(): Promise<void>;
destroy(): void;
get isSupported(): boolean;
get isEnabled(): boolean;
get isFullscreen(): boolean;
get element(): Element | null;
get state(): FullscreenState;
get performanceData(): FullscreenPerformanceMetrics;
request(element?: Element, requestOptions?: {
navigationUI?: 'auto' | 'hide' | 'show';
}): Promise<void>;
exit(): Promise<void>;
toggle(element?: Element, options?: {
navigationUI?: 'auto' | 'hide' | 'show';
}): Promise<void>;
private initEventListeners;
private removeEventListeners;
private handleFullscreenChange;
private handleFullscreenError;
private updateCurrentState;
private detectChangeEventName;
private detectErrorEventName;
private getRequestMethodName;
private getExitMethodName;
}
declare const fullscreen: FullscreenManager;
type core_ApiResponse<T = any> = ApiResponse<T>;
type core_BaseManager<T extends BaseOptions$1 = BaseOptions$1> = BaseManager<T>;
declare const core_BaseManager: typeof BaseManager;
type core_BaseOptions = BaseOptions;
type core_Cache<T = any> = Cache<T>;
declare const core_Cache: typeof Cache;
type core_CacheConfig = CacheConfig;
type core_CacheEntry<T = any> = CacheEntry<T>;
type core_CustomError = CustomError;
declare const core_CustomError: typeof CustomError;
type core_ErrorContext = ErrorContext;
type core_ErrorHandler = ErrorHandler;
declare const core_ErrorHandler: typeof ErrorHandler;
type core_ErrorType = ErrorType;
declare const core_ErrorType: typeof ErrorType;
type core_EventEmitter = EventEmitter;
declare const core_EventEmitter: typeof EventEmitter;
type core_EventListenerConfig = EventListenerConfig;
type core_LogEntry = LogEntry;
type core_LogLevel = LogLevel;
declare const core_LogLevel: typeof LogLevel;
type core_Logger = Logger;
declare const core_Logger: typeof Logger;
type core_ProcessedError = ProcessedError;
declare namespace core {
export { core_BaseManager as BaseManager, core_Cache as Cache, core_CustomError as CustomError, core_ErrorHandler as ErrorHandler, core_ErrorType as ErrorType, core_EventEmitter as EventEmitter, core_LogLevel as LogLevel, core_Logger as Logger };
export type { core_ApiResponse as ApiResponse, core_BaseOptions as BaseOptions, core_CacheConfig as CacheConfig, core_CacheEntry as CacheEntry, core_ErrorContext as ErrorContext, EventListener$1 as EventListener, core_EventListenerConfig as EventListenerConfig, core_LogEntry as LogEntry, core_ProcessedError as ProcessedError };
}
type ElementSelector = string | Element | null;
interface EventListenerOptions$1 extends AddEventListenerOptions {
once?: boolean;
capture?: boolean;
passive?: boolean;
}
interface BrowserCompatibility {
supported: boolean;
prefixedName?: string;
prefix?: string;
}
interface DOMPerformanceConfig {
enableBatch?: boolean;
batchDelay?: number;
useFragment?: boolean;
}
declare function isElement(element: any): element is Element;
declare function isHTMLElement(element: any): element is HTMLElement;
declare function isDocument(element: any): element is Document;
declare function getElement(selector: ElementSelector): Element | null;
declare function getElements(selector: string): Element[];
declare function checkBrowserSupport(feature: string): BrowserCompatibility;
declare function getPrefixedCSSProperty(property: string): string | null;
declare function supportsCSSFeature(property: string, value?: string): boolean;
declare function supportsHTML5Feature(feature: string): boolean;
declare function isSupported(feature: string): boolean;
declare function getPrefixedProperty(property: string): string | null;
declare function addEventListener(target: ElementSelector | Document | Window, event: string, handler: EventListener, options?: EventListenerOptions$1): () => void;
declare function removeEventListener(target: ElementSelector | Document | Window, event: string, handler: EventListener, options?: EventListenerOptions$1): void;
declare function removeAllEventListeners(target: ElementSelector | Document | Window): void;
declare function createCustomEvent(type: string, detail?: any, options?: CustomEventInit): CustomEvent;
declare function dispatchCustomEvent(target: ElementSelector, type: string, detail?: any, options?: CustomEventInit): boolean;
declare function delegate(container: ElementSelector, selector: string, event: string, handler: (event: Event, target: Element) => void, options?: EventListenerOptions$1): () => void;
declare function batchDOMOperations(operations: (() => void)[]): void;
declare function createDocumentFragment(): DocumentFragment;
declare function appendElements(container: ElementSelector, elements: (Element | string)[], config?: DOMPerformanceConfig): void;
declare function setStyles(target: ElementSelector, styles: Partial<CSSStyleDeclaration>): void;
declare function setAttributes(target: ElementSelector, attributes: Record<string, string>): void;
declare function measureElement(target: ElementSelector): DOMRect | null;
declare function isElementInViewport(target: ElementSelector, threshold?: number): boolean;
declare function ready(callback: () => void): void;
declare function waitForElement(selector: string, timeout?: number): Promise<Element>;
declare function flushBatchedOperations(): void;
type ImageFormat = 'jpeg' | 'png' | 'gif' | 'webp' | 'bmp' | 'svg' | 'ico';
declare enum FileType {
IMAGE = "image",
AUDIO = "audio",
VIDEO = "video",
DOCUMENT = "document",
ARCHIVE = "archive",
CODE = "code",
OTHER = "other"
}
interface ImageCompressOptions {
quality?: number;
maxWidth?: number;
maxHeight?: number;
format?: ImageFormat;
maintainAspectRatio?: boolean;
backgroundColor?: string;
}
interface ImageConvertOptions {
format: ImageFormat;
quality?: number;
preserveMetadata?: boolean;
}
interface ImageDimensions {
width: number;
height: number;
aspectRatio: number;
}
interface FileInfo {
name: string;
size: number;
type: FileType;
mimeType: string;
extension: string;
lastModified: number;
path?: string;
}
interface FileTypeResult {
isImage: boolean;
isAudio: boolean;
isVideo: boolean;
isDocument?: boolean;
type: FileType;
mimeType: string;
extension: string;
isSupported?: boolean;
}
interface FileReadOptions {
readAs?: 'text' | 'dataURL' | 'arrayBuffer' | 'binaryString';
encoding?: string;
enableProgress?: boolean;
onProgress?: (progress: number) => void;
}
interface FileReadResult<T = any> {
result: T;
fileInfo: FileInfo;
duration: number;
success: boolean;
error?: string;
}
declare enum DeviceType {
DESKTOP = "desktop",
MOBILE = "mobile",
TABLET = "tablet",
TV = "tv",
WEARABLE = "wearable",
UNKNOWN = "unknown"
}
declare enum OSType {
WINDOWS = "windows",
MACOS = "macos",
LINUX = "linux",
ANDROID = "android",
IOS = "ios",
UNKNOWN = "unknown"
}
declare enum BrowserType {
CHROME = "chrome",
FIREFOX = "firefox",
SAFARI = "safari",
EDGE = "edge",
IE = "ie",
OPERA = "opera",
UNKNOWN = "unknown"
}
type QueryParams$1 = Record<string, string | string[] | undefined>;
declare enum FontStyle {
NORMAL = "normal",
ITALIC = "italic",
OBLIQUE = "oblique"
}
declare enum FontWeight {
THIN = 100,
EXTRA_LIGHT = 200,
LIGHT = 300,
NORMAL = 400,
MEDIUM = 500,
SEMI_BOLD = 600,
BOLD = 700,
EXTRA_BOLD = 800,
BLACK = 900
}
declare enum ClipboardDataType {
TEXT = "text/plain",
HTML = "text/html",
RTF = "text/rtf",
IMAGE = "image/png",
JSON = "application/json"
}
interface EventListenerOptions extends AddEventListenerOptions {
once?: boolean;
capture?: boolean;
passive?: boolean;
signal?: AbortSignal;
}
declare function isBase64(str: string): boolean;
declare function isBlob(obj: any): obj is Blob;
declare function isFile(obj: any): obj is File;
declare function getFileExtension(filename: string): string;
declare function getExtensionFromMimeType(mimeType: string): string;
declare function getMimeTypeFromExtension(extension: string): string;
declare function checkFileType(file: File | string): FileTypeResult;
declare function generateRandomFileName(extension?: string): string;
declare function getMimeTypeFromDataURL(dataURL: string): string;
declare function getBase64FromDataURL(dataURL: string): string;
declare function delay(ms: number): Promise<void>;
interface FileManagerOptions extends BaseOptions$1 {
maxFileSize?: number;
allowedTypes?: string[];
enableTypeValidation?: boolean;
enableSizeValidation?: boolean;
defaultReadAs?: 'text' | 'dataURL' | 'arrayBuffer' | 'binaryString';
}
interface FileConversionResult<T = any> {
result: T;
originalInfo?: FileInfo;
convertedInfo?: FileInfo;
duration: number;
fromCache: boolean;
}
declare class FileManager extends BaseManager<FileManagerOptions> {
private readonly CHUNK_SIZE;
protected getDefaultOptions(): Required<FileManagerOptions>;
initialize(): Promise<void>;
destroy(): void;
urlToBase64(url: string): Promise<FileConversionResult<string>>;
blobToBase64(blob: Blob): Promise<FileConversionResult<string>>;
fileToBase64(file: File): Promise<FileConversionResult<string>>;
base64ToBlob(base64: string): FileConversionResult<Blob>;
base64ToFile(base64: string, filename?: string): FileConversionResult<File>;
fileToBlob(file: File): FileConversionResult<Blob>;
blobToFile(blob: Blob, filename?: string): FileConversionResult<File>;
readFile(file: File, options?: FileReadOptions): Promise<FileReadResult>;
checkFileType(file: File | string): FileTypeResult;
validateFile(file: File): {
valid: boolean;
errors: string[];
};
private checkBrowserSupport;
private isAllowedFileType;
private extractFileInfo;
}
declare function urlToBase64(url: string): Promise<string>;
declare function blobToBase64(blob: Blob): Promise<string>;
declare function fileToBase64(file: File): Promise<string>;
declare function base64ToBlob(base64: string): Blob;
declare function base64ToFile(base64: string, filename?: string): File;
declare function fileToBlob(file: File): Blob;
declare function blobToFile(blob: Blob, filename?: string): File;
interface ImageManagerOptions extends BaseOptions$1 {
maxImageSize?: number;
defaultQuality?: number;
defaultFormat?: ImageFormat;
enableSizeValidation?: boolean;
supportedFormats?: ImageFormat[];
canvasContextOptions?: CanvasRenderingContext2DSettings;
}
interface ImageProcessResult<T = any> {
result: T;
originalInfo?: ImageInfo;
processedInfo?: ImageInfo;
duration: number;
fromCache: boolean;
compressionRatio?: number;
}
interface ImageInfo extends FileInfo {
dimensions: ImageDimensions;
isAnimated?: boolean;
colorDepth?: number;
}
declare class ImageManager extends BaseManager<ImageManagerOptions> {
private canvas?;
private context?;
protected getDefaultOptions(): Required<ImageManagerOptions>;
initialize(): Promise<void>;
destroy(): void;
blobToDataURL(blob: Blob): Promise<ImageProcessResult<string>>;
imageToDataURL(image: HTMLImageElement, format?: ImageFormat, quality?: number): ImageProcessResult<string>;
dataURLToImage(dataURL: string): Promise<ImageProcessResult<HTMLImageElement>>;
dataURLtoBlob(dataURL: string): ImageProcessResult<Blob>;
dataURLtoImgBlob(dataURL: string): ImageProcessResult<Blob>;
dataURLtoFile(dataURL: string, filename?: string): ImageProcessResult<File>;
imgConvert(imageFile: File, options: ImageConvertOptions): Promise<ImageProcessResult<File>>;
imgCompress(imageFile: File, options?: ImageCompressOptions): Promise<ImageProcessResult<File>>;
getImageDimensions(imageFile: File): Promise<ImageDimensions>;
private checkBrowserSupport;
private initializeCanvas;
private createImageFromFile;
private extractImageInfo;
private hashString;
}
declare function blobToDataURL(blob: Blob): Promise<string>;
declare function imageToDataURL(image: HTMLImageElement, format?: ImageFormat, quality?: number): string;
declare function dataURLToImage(dataURL: string): Promise<HTMLImageElement>;
declare function dataURLtoBlob(dataURL: string): Blob;
declare function dataURLtoImgBlob(dataURL: string): Blob;
declare function dataURLtoFile(dataURL: string, filename?: string): File;
declare function imgConvert(imageFile: File, options: ImageConvertOptions): Promise<File>;
declare function imgCompress(imageFile: File, options?: ImageCompressOptions): Promise<File>;
interface FeatureDetectionResult {
supported: boolean;
prefixedName?: string;
prefix?: string;
method: 'property' | 'method' | 'css' | 'api' | 'custom';
timestamp: number;
}
interface BrowserAdapterConfig {
enableCache?: boolean;
cacheTimeout?: number;
debug?: boolean;
customPrefixes?: string[];
}
interface BrowserInfo {
name: string;
version: string;
engine: string;
mobile: boolean;
os: string;
}
declare class BrowserAdapter {
private cache;
private logger;
private errorHandler;
private config;
private readonly VENDOR_PREFIXES;
private readonly CSS_PREFIXES;
private browserInfo;
constructor(config?: BrowserAdapterConfig);
isSupported(feature: string): boolean;
getPrefixedProperty(property: string): string | null;
getPrefixedMethod(methodName: string, target?: any): Function | null;
getPrefixedCSSProperty(property: string): string | null;
detectFeature(feature: string, method?: FeatureDetectionResult['method'], target?: any): FeatureDetectionResult;
private detectProperty;
private detectMethod;
private detectCSSProperty;
private detectAPI;
private detectCustomFeature;
private getPrefixedName;
private getNestedProperty;
getBrowserInfo(): BrowserInfo;
addEventListenerCompat(element: Element | Document | Window, event: string, handler: EventListener, options?: AddEventListenerOptions): () => void;
clearCache(): void;
getCacheStats(): {
size: number;
hitRate: number;
maxSize: number;
};
destroy(): void;
}
declare function getBrowserAdapter(config?: BrowserAdapterConfig): BrowserAdapter;
interface FontOptions$1 {
timeout?: number;
retries?: number;
cache?: boolean;
concurrency?: number;
detectionThreshold?: number;
}
interface FontCheckResult$1 {
name: string;
loaded: boolean;
status: string;
loadTime?: number;
error?: string;
}
interface FontLoadResult$1 {
success: boolean;
allFonts: FontCheckResult$1[];
failedFonts?: FontCheckResult$1[];
totalLoadTime?: number;
}
declare function createFont(options?: FontOptions$1): Promise<FontManager>;
declare function checkFont(fontName: string, options?: FontOptions$1): Promise<FontCheckResult$1>;
declare function checkFonts(fontNames: string[], options?: FontOptions$1): Promise<FontLoadResult$1>;
declare function addFont(fontName: string, url: string, options?: FontFaceDescriptors, checkerOptions?: FontOptions$1): Promise<boolean>;
declare function addFontFace(font: FontFace, options?: FontOptions$1): Promise<boolean>;
declare function deleteFont(font: FontFace | string, options?: FontOptions$1): Promise<boolean>;
declare function clearFonts(options?: FontOptions$1): Promise<boolean>;
declare function isFontLoaded(fontName: string): boolean;
declare function waitForFonts(fontNames: string[], timeout?: number): Promise<FontLoadResult$1>;
declare function loadFont(fontName: string, url: string, options?: FontFaceDescriptors, onSuccess?: () => void, onError?: (error: any, isCORSError: boolean) => void): Promise<boolean>;
declare function isCrossDomainUrl(url: string): boolean;
declare function isFontCORSError(error: any): boolean;
declare function addFonts(fonts: Array<{
name: string;
url: string;
options?: FontFaceDescriptors;
}>, managerOptions?: FontOptions$1): Promise<Array<{
name: string;
success: boolean;
error?: string;
}>>;
declare function preloadFonts(fontNames: string[], options?: FontOptions$1): Promise<{
available: string[];
unavailable: string[];
cached: string[];
}>;
declare function getFontPerformanceStats(options?: FontOptions$1): Promise<{
totalFontsChecked: number;
cacheHitRate: number;
averageCheckTime: number;
loadingFonts: number;
loadedFonts: number;
failedFonts: number;
}>;
declare function cleanupFontManager(options?: FontOptions$1): Promise<void>;
interface FontCheckResult {
name: string;
loaded: boolean;
status: string;
loadTime?: number;
error?: string;
}
interface FontLoadResult {
success: boolean;
allFonts: FontCheckResult[];
failedFonts?: FontCheckResult[];
totalLoadTime?: number;
}
interface FontOptions extends BaseOptions$1 {
timeout?: number;
retries?: number;
cache?: boolean;
concurrency?: number;
detectionThreshold?: number;
}
interface FontLoadState {
family: string;
status: 'loading' | 'loaded' | 'error' | 'timeout';
startTime: number;
endTime?: number;
error?: Error;
retryCount: number;
}
declare class FontManager extends BaseManager<FontOptions> {
private addedFonts;
private loadingStates;
private systemFonts;
constructor(options?: FontOptions);
protected getDefaultOptions(): Required<FontOptions>;
initialize(): Promise<void>;
destroy(): void;
addFont(fontName: string, url: string, options?: FontFaceDescriptors): Promise<boolean>;
private loadFontWithRetry;
check(fontNames?: string | string[]): Promise<FontLoadResult>;
private checkMultipleFonts;
private sortFontsByPriority;
private checkSingleFont;
private performFontCheck;
private checkWithFontFaceAPI;
private performFontDetectionTest;
private checkAllFonts;
addFontFace(font: FontFace): boolean;
deleteFont(font: FontFace | string): boolean;
clearFonts(): boolean;
getFontLoadState(fontName: string): FontLoadState | undefined;
getAllFontLoadStates(): Map<string, FontLoadState>;
addFonts(fonts: Array<{
name: string;
url: string;
options?: FontFaceDescriptors;
}>): Promise<Array<{
name: string;
success: boolean;
error?: string;
}>>;
preloadFonts(fontNames: string[]): Promise<{
available: string[];
unavailable: string[];
cached: string[];
}>;
cleanup(): void;
getPerformanceStats(): {
totalFontsChecked: number;
cacheHitRate: number;
averageCheckTime: number;
loadingFonts: number;
loadedFonts: number;
failedFonts: number;
};
private isCrossDomainUrl;
private isCORSError;
}
interface UrlInfo {
url: string;
protocol: string;
hostname: string;
port: string;
origin: string;
pathname: string;
search: string;
hash: string;
host: string;
}
interface QueryParams {
[key: string]: string | string[] | undefined;
}
interface UrlManagerOptions extends BaseOptions {
url?: string;
validateUrls?: boolean;
allowedProtocols?: string[];
maxUrlLength?: number;
}
declare class UrlManager extends BaseManager<UrlManagerOptions> {
private _url;
private _urlObj;
constructor(options?: UrlManagerOptions | string);
protected getDefaultOptions(): Required<UrlManagerOptions>;
initialize(): Promise<void>;
destroy(): void;
getUrlInfo(): UrlInfo;
getQuery(): QueryParams;
setQuery(params: QueryParams): this;
addQuery(params: QueryParams): this;
removeQuery(keys: string | string[]): this;
setHash(hash: string): this;
setPathname(pathname: string): this;
toString(): string;
reset(url: string): this;
isValidUrl(url: string): boolean;
private _updateUrl;
private _validateUrl;
}
declare function createUrlManager(options?: UrlManagerOptions): UrlManager;
declare const _default: {
core: typeof core;
fullscreen: FullscreenManager;
clipboard: ClipboardManager;
file: {
FileType: typeof FileType;
DeviceType: typeof DeviceType;
OSType: typeof OSType;
BrowserType: typeof BrowserType;
FontStyle: typeof FontStyle;
FontWeight: typeof FontWeight;
ClipboardDataType: typeof ClipboardDataType;
ModuleState: typeof ModuleState;
LogLevel: typeof LogLevel$1;
AsyncOperationStatus: typeof AsyncOperationStatus;
ErrorType: typeof ErrorType$1;
ErrorSeverity: typeof ErrorSeverity;
getBrowserAdapter: typeof getBrowserAdapter;
isElement(element: any): element is Element;
isHTMLElement(element: any): element is HTMLElement;
isDocument(element: any): element is Document;
getElement(selector: ElementSelector): Element | null;
getElements(selector: string): Element[];
checkBrowserSupport(feature: string): BrowserCompatibility;
getPrefixedCSSProperty(property: string): string | null;
supportsCSSFeature(property: string, value?: string): boolean;
supportsHTML5Feature(feature: string): boolean;
isSupported(feature: string): boolean;
getPrefixedProperty(property: string): string | null;
addEventListener(target: ElementSelector | Document | Window, event: string, handler: EventListener, options?: EventListenerOptions$1): () => void;
removeEventListener(target: ElementSelector | Document | Window, event: string, handler: EventListener, options?: EventListenerOptions$1): void;
removeAllEventListeners(target: ElementSelector | Document | Window): void;
createCustomEvent(type: string, detail?: any, options?: CustomEventInit): CustomEvent;
dispatchCustomEvent(target: ElementSelector, type: string, detail?: any, options?: CustomEventInit): boolean;
delegate(container: ElementSelector, selector: string, event: string, handler: (event: Event, target: Element) => void, options?: EventListenerOptions$1): () => void;
batchDOMOperations(operations: (() => void)[]): void;
createDocumentFragment(): DocumentFragment;
appendElements(container: ElementSelector, elements: (Element | string)[], config?: DOMPerformanceConfig): void;
setStyles(target: ElementSelector, styles: Partial<CSSStyleDeclaration>): void;
setAttributes(target: ElementSelector, attributes: Record<string, string>): void;
measureElement(target: ElementSelector): DOMRect | null;
isElementInViewport(target: ElementSelector, threshold?: number): boolean;
ready(callback: () => void): void;
waitForElement(selector: string, timeout?: number): Promise<Element>;
flushBatchedOperations(): void;
blobToDataURL(blob: Blob): Promise<string>;
imageToDataURL(image: HTMLImageElement, format?: ImageFormat, quality?: number): string;
dataURLToImage(dataURL: string): Promise<HTMLImageElement>;
dataURLtoBlob(dataURL: string): Blob;
dataURLtoImgBlob(dataURL: string): Blob;
dataURLtoFile(dataURL: string, filename?: string): File;
imgConvert(imageFile: File, options: ImageConvertOptions): Promise<File>;
imgCompress(imageFile: File, options?: ImageCompressOptions): Promise<File>;
ImageManager: typeof ImageManager;
urlToBase64(url: string): Promise<string>;
blobToBase64(blob: Blob): Promise<string>;
fileToBase64(file: File): Promise<string>;
base64ToBlob(base64: string): Blob;
base64ToFile(base64: string, filename?: string): File;
fileToBlob(file: File): Blob;
blobToFile(blob: Blob, filename?: string): File;
FileManager: typeof FileManager;
isBase64(str: string): boolean;
isBlob(obj: any): obj is Blob;
isFile(obj: any): obj is File;
getFileExtension(filename: string): string;
getExtensionFromMimeType(mimeType: string): string;
getMimeTypeFromExtension(extension: string): string;
checkFileType(file: File | string): FileTypeResult;
generateRandomFileName(extension?: string): string;
getMimeTypeFromDataURL(dataURL: string): string;
getBase64FromDataURL(dataURL: string): string;
delay(ms: number): Promise<void>;
};
font: typeof FontManager;
url: typeof UrlManager;
device: {
DeviceDetector: typeof DeviceDetector;
getDeviceInfo: typeof getDeviceInfo;
getDeviceInfoSync: typeof getDeviceInfoSync;
createDeviceDetector: typeof createDeviceDetector;
isDeviceType: typeof isDeviceType;
};
ua: {
UA: typeof UA;
getCurrentUA: typeof getCurrentUA;
parseUserAgent: typeof parseUserAgent;
isCompatible: typeof isCompatible;
};
};
export { BaseManager, Cache, ClipboardManager, CustomError, DeviceDetector, ErrorHandler, ErrorType, EventEmitter, FileManager, FontManager, FullscreenManager, ImageManager, LogLevel, Logger, UAManager, UrlManager, addEventListener, addFont, addFontFace, addFonts, appendElements, base64ToBlob, base64ToFile, batchDOMOperations, blobToBase64, blobToDataURL, blobToFile, checkBrowserSupport, checkFileType, checkFont, checkFonts, cleanupFontManager, clearFonts, clipboard, compareVersions, createCustomEvent, createDocumentFragment, createFont, createUrlManager, dataURLToImage, dataURLtoBlob, dataURLtoFile, dataURLtoImgBlob, _default as default, delay, delegate, deleteFo