chroma.js icon indicating copy to clipboard operation
chroma.js copied to clipboard

Updated fork

Open regorxxx opened this issue 7 months ago • 15 comments

An updated fork can be found here, with all dependencies updated, vulnerabilities fixed and new features (along relevant pendant pull request).

https://github.com/regorxxx/chroma.js

Docs have also been updated. Can be replaced directly without changes.

regorxxx avatar Nov 08 '23 18:11 regorxxx

@gka @regorxxx @iyinchao @stormwarning @salvoravida @artoria2e5 @OlaoluwaM @tstaylor7 @tremby @taisukef

Hello you all! I tagged you because you're either the original owner of this repo, or someone who most-recently made significant features and updates in a fork of this repo (I looked at the network graph).

I figured, so as not to let this project get stale, perhaps we can all get together and help maintain a fork of it.

I started a fork from @regorxxx's in a new org, and I've invited you all to the org (anyone else want to join, please comment here!):

https://github.com/chroma-js/chroma.js

I will taking some inspiration from @taisukef's fork and starting from @regorxxx's fork making it all work as vanilla ES Modules, and deleting all traces of CommonJS (we can optionally add a CommonJS build if people really need that, but CommonJS is the past, ES Modules are the present and the future).

trusktr avatar Nov 29 '23 20:11 trusktr

Thanks for pointing it out. If I reach for Chroma again at some point I'll consider using one fork or the other. But in truth I haven't felt much need for Chroma since browsers improved their colour space support to include things like Oklab and Oklch.

tremby avatar Nov 29 '23 21:11 tremby

Oh I see you invited me to join the org too. I'm not going to at this point; one reason is that I feel a bit uncomfortable about it being named "chroma-js" without signoff (as far as I know) from the original author.

tremby avatar Nov 29 '23 21:11 tremby

Thank you for pointing it out! I use ES Modules on browsers and Deno, so I forked and converted CommonJS sources. https://github.com/code4fukui/chroma-es/tree/es/src I hope you will make good use of this repository. Please let us know if there's anything missing or if you have any suggestions.

taisukef avatar Nov 29 '23 21:11 taisukef

Oh I see you invited me to join the org too. I'm not going to at this point; one reason is that I feel a bit uncomfortable about it being named "chroma-js" without signoff (as far as I know) from the original author.

That's easy to change. The original author @gka is also invited.

GitHub does not allow user names or org names with a period, so github.com/chroma.js is not allowed, and github.com/chromajs and github.com/chroma are both already taken by unrelated projects. So github.com/chroma-js was the only close-enough option.

trusktr avatar Nov 30 '23 00:11 trusktr

Alright folks, the great work from @regorxxx and @taisukef is merged. The code is now all ES Modules:

https://github.com/chroma-js/chroma.js

Unlike your fork @taisukef, this keeps package.json and scripts for building and publishing for Node.js. But otherwise, most of the ESM conversions merged cleanly, and I only had to additionally convert @regorxxx's new and files. I think this should also work in Deno. Let me know if you can import from here for example:

https://raw.githack.com/chroma-js/chroma.js/main/index.js

When I run the docs, the colorful sidebar is missing (even on your fork @regorxxx):

Screenshot 2023-11-29 at 4 41 31 PM

Need to figure out where that went.

All scripts except test are working. The tests need to be updated to a modern test runner because the current test files are CommonJS and they cannot import ES Modules. I'll update the test runner next...

The dev process does not work in Windows at all. That is going to be fixed...

The root /chroma.js (and all other build outputs) are now ES Modules, and the changelog now shows that import is required for importing:

  • BREAKING: conversion of code base to ES Modules. All build outputs are now ES Modules. The global var script is no longer available, use import to import chroma.js. For example:
    <script type="module">
      import chroma from 'https://raw.githack.com/chroma-js/chroma.js/main/index.js'
      // ... use chroma as before ...
    </script>
    

trusktr avatar Nov 30 '23 00:11 trusktr

I force pushed to https://github.com/chroma-js/chroma.js as there was one small mistake in the merge with an import path, now the test/html/*.html files all work as expected. @taisukef curious to see if this works for you in Deno now (it would have failed until this force push).

trusktr avatar Nov 30 '23 00:11 trusktr

Aaaaaaalrighty! An initial working test for Deno is pushed @taisukef.

    "test:deno": "deno run test/test-deno.js",

trusktr avatar Nov 30 '23 00:11 trusktr

Most tests passing in Chrome browser running as vanilla ES Modules. Need to iron a few out:

Chrome: |██████████████████████████████| 50/50 test files | 1956 passed, 69 failed

Finished running tests, watching for file changes...

trusktr avatar Nov 30 '23 10:11 trusktr

@regorxxx @taisukef there's one particular test where the numbers are quite different between both of your forks. I'm wondering why that is. Here are the tests in question:

https://github.com/chroma-js/chroma.js/blob/340438a65d16e594e587f7fe72b98b0f924294d6/test/bezier.test.js#L133-L238

Both of you forked from this repo's 2.4.2 release, and one fork changed something that modified the numbers and I'm wondering what's correct.

trusktr avatar Nov 30 '23 19:11 trusktr

@trusktr The original repo had wrong values and wrong tests.

Also see this: https://github.com/gka/chroma.js/pull/228

I also added proper n-degree bezier interpolation.

All my changes are documented on the changelog ;)

regorxxx avatar Dec 09 '23 14:12 regorxxx

Once I have time, if I find working with ES modules is easier for me, I will help with that.

Right now I'm using chroma within a context where modules are not available and only just plain JS loading of files or require. If I can not work around that, will continue developing my fork.

regorxxx avatar Dec 09 '23 14:12 regorxxx

The original repo had wrong values and wrong tests. Also see this: #228 documented on the changelog ;)

@regorxxx ah, thanks!

if I find working with ES modules is easier for me, I will help with that.

I hope you will!

ESM is the future-forward module standard for all JS runtimes, so we should support it as a default anyway.

We can add CommonJS or global build back fairly easily, but:

context where modules are not available and only just plain JS loading of files or require

Out of curiousity, what context is that and how does it stop you from using ESM? Is it an old browser or Node version? All browser and non-browser JS runtimes today support import(...) in any script (module or not).

trusktr avatar Dec 10 '23 07:12 trusktr

@trusktr Not a browser related context, but foobar2000. There are JS plugins for it, to create any frontend/backend element, so I can use most libraries with full support for ES6. But import/require, etc. are not available. I can polyfill require, but can not do that with import.

regorxxx avatar Dec 10 '23 09:12 regorxxx

Added a few more features on 2.7.0, along a fix to the 'npm run docs-preview' command which was not working on some OSes.

Also a logo for the library image

regorxxx avatar Dec 26 '23 18:12 regorxxx

@trusktr Not a browser related context, but foobar2000. There are JS plugins for it, to create any frontend/backend element, so I can use most libraries with full support for ES6. But import/require, etc. are not available.

Ah I see. We can remedy that. We can have a build step that procudes the global build (f.e. UMD format or similar). That way by default people can use ES modules but old environments can still have an option.

trusktr avatar Feb 26 '24 06:02 trusktr