Release v1.1.1
Overview
This release focuses on resolving build issues in Next.js and enhancing the robustness of environment handling within the library. With a centralized environment detection function, the library now ensures seamless compatibility between server-side rendering (SSR) and client-side environments, requiring no manual adjustments from developers.
What's New
1. Centralized Environment Detection
- Introduced a unified
getWindow
function to safely handle environment detection:getWindow(): Window | undefined
:- Returns the
window
object when in a browser environment. - Returns
undefined
when running in a server environment.
- Returns the
- Example implementation:
export function getWindow(): Window | undefined { if (typeof window === "undefined") { return undefined; } return window; }
- Benefit: This centralization simplifies code and eliminates the need for developers to manage environment-specific checks.
2. Seamless Compatibility
- The library now automatically adapts to the runtime environment, whether it’s server-side (Next.js SSR) or client-side (browser).
- No additional setup or configuration is required by developers.
3. Improved Error Handling
- Enhanced error messages when browser-specific features are used incorrectly, making it easier for developers to diagnose potential issues.
4. Comprehensive Testing
- Expanded the test suite to cover:
- Behavior of the
getWindow
function in SSR and client environments. - Integration with key features like
Hotkeys
andGlobalKeyboardListener
in both development and production scenarios.
- Behavior of the
Bug Fixes
- Fixed a critical issue where the library caused build failures in Next.js due to accessing the
window
object during SSR.