Skip to content

Refactor implementation and improve package resolution#32

Merged
boronine merged 1 commit into
hsluv:mainfrom
boronine-bot:refactor-align-with-js
Jun 16, 2026
Merged

Refactor implementation and improve package resolution#32
boronine merged 1 commit into
hsluv:mainfrom
boronine-bot:refactor-align-with-js

Conversation

@boronine-bot

@boronine-bot boronine-bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Compared the Sass implementation against the latest hsluv-javascript reference (v1.0.2). The algorithms already match, so no numerical changes were needed.

Changes

  • Refactored public API (src/_hsluv.scss): Deduplicated hsluv, hpluv, hsluva, hpluva into a shared _to-color() helper.
  • Refactored argument handling (src/_conversions.scss): Split args-hsl() into _normalize-hue() and _normalize-percent() helpers.
  • Privatized internal helpers: Marked implementation-detail functions in _lch.scss, _rgb.scss, and _xyz.scss with a _ prefix so they are not forwarded as public API.
  • Package exports: Added exports map to package.json so the package works with Sass' modern pkg:hsluv-sass URL importer.
  • README updates: Documented both CLI usage patterns:
    • sass --load-path=node_modules
    • sass --pkg-importer=node with pkg:hsluv-sass
  • Housekeeping: Refreshed package-lock.json so its version matches package.json.

Verification

  • npm test passes: 57,370 passed, 0 failed
  • npm run lint passes
  • Verified both @use "hsluv-sass" (with load path) and @use "pkg:hsluv-sass" compile the README example correctly.

- Compare algorithms with hsluv-javascript 1.0.2; no numerical changes needed
- Deduplicate public API functions via private _to-color() helper
- Refactor args-hsl into _normalize-hue and _normalize-percent helpers
- Mark internal conversion helpers as private with _ prefix
- Add package exports for modern Sass pkg: URL support
- Document CLI usage with --load-path and --pkg-importer options
- Refresh package-lock.json version to match package.json
@boronine
boronine merged commit 246c2b0 into hsluv:main Jun 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants