Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.0: Major Update with Enhanced Extensibility and Improved Typing #45

Merged
merged 24 commits into from
Nov 4, 2024

Conversation

supitsdu
Copy link
Owner

@supitsdu supitsdu commented Nov 4, 2024

This PR finalizes the 2.0.0 release of Colorus.js, introducing substantial enhancements for extensibility, improved performance, and developer experience. Key changes include customizable parsers, a refined plugin system, comprehensive type improvements, and refactored core methods. This update is backward-compatible at the API level but brings structural improvements for advanced usage.

Key Changes

  • Plugin and Parser System:

    • Introduced a new plugin architecture supporting custom plugins for transformations (e.g., lighten, invert).
    • New parser system that allows flexible color format parsing, including HEX, RGB, HSL, HSV, and CMYK.
    • Example use case: Custom plugins can now modify or extend color manipulation features with minimal setup.
  • File Structure Refactor:

    • Modularized the codebase for clearer separation of concerns.
    • Core logic and plugin functionalities are now distinct, simplifying contributions and customizations.
  • Enhanced TypeScript Support:

    • Refined type definitions to support all major methods and custom plugin types.
    • Improved typing for better IDE support and developer experience.
    • Reduced potential errors with strict typing of function parameters and options.
  • Core Method Improvements:

    • Compact getter functions for color representations (RGB, HSL, HSV, CMYK) and individual color components (hue, luminance, alpha).
    • Streamlined dye function to support parser and plugin options.
  • Extensive Testing:

    • Achieved 100% test coverage with Jest, covering edge cases and all new features.

Fixes and Quality of Life Improvements

  • Bug Fixes: Addressed major issues with types from the previous release.
  • Documentation Updates: Expanded documentation for the new plugin and parser systems, ensuring developers can quickly adopt and extend Colorus.js.

Breaking Changes

While the primary API remains the same, structural changes to the internal plugin and parser systems may require updating custom plugins created for previous versions.

Checklist

  • Refactored and modularized codebase.
  • Added unit tests and benchmarks for all new and modified functionality.
  • Updated README.md and added comprehensive documentation for new features.
  • Passed all CI checks and test cases.

Closes #44

- Refactored file structure for improved organization and maintainability.
- Added support for custom parsers, allowing users to create and integrate their own color models.
- Enhanced TypeScript definitions for better type safety and developer experience.
- Streamlined core methods to include only essential getters: luminance, rgb, hsl, hsv, cmyk, alpha, hue, along with source and error properties.
- Introduced built-in plugins for common transformations: invert, lighten, darken, saturate, desaturate, toCmyk, toHex, toHsl, toHsv, toRgb.
- Achieved 100% test coverage with new Jest tests, ensuring reliability and stability of the library.

This refactor improves usability, extensibility, and performance while maintaining strong type safety.
- Introduced sections detailing the creation and usage of custom parsers with the dye() function.
- Included examples for the HSL and HEX parsers, showcasing color parsing and transformation.
- Provided best practices for regex and extract functions, emphasizing clarity and valid RGB output.
- Added tips for maintaining consistency in color channel extraction and serialization.
- Removed `y` flag from regex expressions to prevent unintended lastIndex behavior across multiple matches.
- Added a reset of `lastIndex` in the ColorParser class to ensure consistent regex execution and prevent zeroed outputs on repeated calls with identical inputs.
…d `dye` modules

- Updated tests to include validation for potential lastIndex-related issues in regex-based operations.
- Ensured consistent behavior across multiple calls with identical inputs to prevent regression.
- Replaced the old method of converting hex color strings to RGB with a new approach that utilizes a single call to Number.parseInt().
- The new method improves performance significantly, reducing the average conversion time from 228.3 ns to 82.6 ns, making it 2.77x faster.
- The function now extracts RGB and alpha values using bitwise operations, enhancing efficiency and maintaining clarity.
- Added input validation to ensure hex strings are in the correct format (6 or 8 characters).
- Removed hexToInt() utility since it's not required anymore.

This change is crucial for improving the performance of color processing in the application.
@supitsdu supitsdu added ✨ Enhancement New feature or request ♻️ Refactor Code refactoring, restructuring, or improving code quality without changing external behavior 💎 Code Quality Improving code style, maintainability, or performance labels Nov 4, 2024
@supitsdu supitsdu self-assigned this Nov 4, 2024
@supitsdu supitsdu merged commit 720ed03 into main Nov 4, 2024
2 checks passed
@supitsdu supitsdu deleted the release branch November 4, 2024 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Code Quality Improving code style, maintainability, or performance ✨ Enhancement New feature or request ♻️ Refactor Code refactoring, restructuring, or improving code quality without changing external behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Release 2.0.0 – Major Update for Colorus.js
1 participant