browserinfo 0.1.7

browser and hardware information.
Documentation
# Code Review (v2) for `browserinfo`

## 1. Summary of Improvements
The recent updates have significantly improved the code's structure and maintainability. Key improvements include:
- **Module Reorganization**: Renaming `broinfomaster.rs` to `browser.rs` and moving it to `src/li/` follows better naming conventions.
- **Trait-based Deserialization**: The introduction of the `FromJsonStr` trait provides a cleaner, more idiomatic way to handle JSON parsing across different structs.
- **Reduced Redundancy**: The `format_version` helper function effectively DRYs up the User Agent parsing logic, which was previously quite repetitive.
- **Modern Rust Features**: Utilizing `std::sync::LazyLock` (available in Rust 1.80+) for the `ua-parser` extractor is more efficient and safe than previous patterns.
- **Comprehensive Testing**: The test suite remains exceptionally thorough, covering a wide range of modern mobile and desktop devices.

## 2. Critical Issues: Typos and Inconsistency
While many typos were addressed in the Rust code, some critical inconsistencies remain that will affect the library's functionality:

- **JavaScript/Rust Mismatch**: 
    - In `src/li/browser.rs`, `device_pixcel_ratio` was correctly renamed to `device_pixel_ratio`.
    - **However**, in `assets/js/broinfo.js` (and its minified version), the key is still spelled `device_pixcel_ratio`.
    - **Impact**: When JavaScript data is sent to Rust, the `device_pixel_ratio` field in the Rust struct will always be `None` (or fail to deserialize) because the keys do not match.
    - **Recommendation**: Fix the spelling in `assets/js/broinfo.js` to match the Rust struct.

- **Persistent Typos in Tests**:
    - Several test comments and names still use `Pixcel` instead of `Pixel` (e.g., `test_user_agent_on_android_emu4_01` mentions `Pixcel_4`).
    - While this doesn't break code, correcting it improves professional quality.

## 3. JavaScript Code Quality
The JavaScript collection scripts could be further refined:

- **Avoid `eval`**: 
    - The use of `eval("navigator." + prop)` in `get_navigator_prop` is non-standard and generally discouraged.
    - **Recommendation**: Use bracket notation: `navigator[prop]`. This is safer and more performant.
- **Simplify `get_timezone`**: 
    - The current implementation uses many nested `if` checks. 
    - **Recommendation**: Use optional chaining or a more concise check:
      ```javascript
      function get_timezone() {
          try {
              return Intl.DateTimeFormat().resolvedOptions().timeZone || '';
          } catch (e) {
              return '';
          }
      }
      ```
- **Typo in variable name**: `v_device_pixcel_ratio` in `broinfo.js` should be `v_device_pixel_ratio`.

## 4. Build and Assets
- **Makefile**: The inclusion of a `minix` target for JavaScript minification is a good practice for ensuring the included strings are as small as possible.
- **Submodules**: Ensure that the `core` submodule (used for `regexes.yaml`) is properly documented in the `README` for developers who clone the repository for the first time.

## 5. Final Verdict
The Rust implementation is now very high quality. The primary remaining task is to sync the JavaScript asset keys with the updated Rust struct names and address the minor quality issues in the JS collection scripts.

---
**Reviewed on**: April 16, 2026