@dbs-portal/core-module-registry
Version:
Core module registry system for automatic module discovery and registration
110 lines • 2.97 kB
TypeScript
/**
* Environment Detection Utilities
*
* Provides utilities to detect the current runtime environment
* and conditionally load appropriate modules.
*/
declare global {
const importScripts: ((url: string) => void) | undefined;
const jest: unknown | undefined;
const vitest: unknown | undefined;
}
export interface EnvironmentInfo {
isBrowser: boolean;
isNode: boolean;
isWebWorker: boolean;
isTest: boolean;
isDevelopment: boolean;
isProduction: boolean;
}
/**
* Detect current environment
*/
export declare function detectEnvironment(): EnvironmentInfo;
export declare const ENV: EnvironmentInfo;
/**
* Conditional module loader
*/
export declare function loadConditionalModule<T>(nodeModule: () => Promise<T>, browserModule: () => Promise<T>): Promise<T>;
/**
* Conditional synchronous module loader
*/
export declare function loadConditionalModuleSync<T>(nodeModule: () => T, browserModule: () => T): T;
/**
* Get platform-specific path separator
*/
export declare function getPathSeparator(): string;
/**
* Get current working directory
*/
export declare function getCurrentDirectory(): string;
/**
* Check if running in development mode
*/
export declare function isDevelopment(): boolean;
/**
* Check if running in production mode
*/
export declare function isProduction(): boolean;
/**
* Check if running in test mode
*/
export declare function isTest(): boolean;
/**
* Check if running in browser
*/
export declare function isBrowser(): boolean;
/**
* Check if running in Node.js
*/
export declare function isNode(): boolean;
/**
* Get environment name
*/
export declare function getEnvironmentName(): string;
/**
* Get platform name
*/
export declare function getPlatformName(): string;
/**
* Create environment-specific logger
*/
export declare function createLogger(prefix?: string): {
debug: (...args: any[]) => void;
info: (...args: any[]) => void;
warn: (...args: any[]) => void;
error: (...args: any[]) => void;
};
/**
* Environment-specific feature flags
*/
export declare const FEATURES: {
canReadFiles: boolean;
canWriteFiles: boolean;
canAccessFileSystem: boolean;
canFetch: boolean;
canMakeHttpRequests: boolean;
canDynamicImport: boolean;
canRequire: boolean;
canScanPackages: boolean;
canScanFileSystem: boolean;
canUseGlob: boolean;
canUseLocalStorage: boolean;
canUseSessionStorage: boolean;
canUseMemoryCache: boolean;
canHotReload: boolean;
canShowDevTools: boolean;
};
/**
* Get feature availability
*/
export declare function hasFeature(feature: keyof typeof FEATURES): boolean;
/**
* Assert feature availability
*/
export declare function assertFeature(feature: keyof typeof FEATURES, message?: string): void;
/**
* Warn about missing features
*/
export declare function warnMissingFeature(feature: keyof typeof FEATURES, fallback?: string): void;
//# sourceMappingURL=environment.d.ts.map