//#region src/modules/env.d.ts /** * 环境检测工具模块 * 提供各种环境检测功能,包括浏览器、Node.js、Web Worker等 */ /** * 检查是否在浏览器环境中 * @returns - 是否在浏览器环境 * @public */ declare function isBrowser(): boolean; /** * 检查是否在Node.js环境中 * @returns - 是否在Node.js环境 * @public */ declare function isNode(): boolean; /** * 检查是否在Web Worker环境中 * @returns - 是否在Web Worker环境 * @public */ declare function isWebWorker(): boolean; /** * 检查document对象是否可用 * @returns - document是否可用 * @public */ declare function isDocumentAvailable(): boolean; /** * 检查localStorage是否可用 * @returns - localStorage是否可用 * @public */ declare function isLocalStorageAvailable(): boolean; /** * 检查sessionStorage是否可用 * @returns - sessionStorage是否可用 * @public */ declare function isSessionStorageAvailable(): boolean; /** * 环境信息接口 * @public */ interface EnvironmentInfo { isBrowser: boolean; isNode: boolean; isWebWorker: boolean; isDocumentAvailable: boolean; isLocalStorageAvailable: boolean; isSessionStorageAvailable: boolean; userAgent: string | undefined; platform: string | undefined; } /** * 获取当前运行环境信息 * @returns - 环境信息对象 * @public */ declare function getEnvironmentInfo(): EnvironmentInfo; /** * 安全执行只能在浏览器环境中运行的代码 * @param callback - 要执行的回调函数 * @param fallback - 环境不支持时的回退函数 * @returns - 执行结果 * @public */ declare function runInBrowser(callback: () => T, fallback?: () => T): T | undefined; /** * 安全执行需要document的代码 * @param callback - 要执行的回调函数 * @param fallback - 环境不支持时的回退函数 * @returns - 执行结果 * @public */ declare function runWithDocument(callback: () => T, fallback?: () => T): T | undefined; //#endregion export { getEnvironmentInfo, isBrowser, isDocumentAvailable, isLocalStorageAvailable, isNode, isSessionStorageAvailable, isWebWorker, runInBrowser, runWithDocument };