williamngan / pts

A library for visualization and creative-coding
https://ptsjs.org
Apache License 2.0
5.16k stars 182 forks source link

fix: infinite recursion in Pt constructor #205

Closed tom-bywild closed 1 year ago

tom-bywild commented 1 year ago

Goals

This PR should fix the infinite recursion happening with react-pts-canvas (https://github.com/williamngan/react-pts-canvas/issues/94). It applies the fix suggested at https://github.com/pixijs/pixijs/pull/9093. The issue seems to be caused by calling super conditionally, therefore I collect the params for super and call it only once at the end.

How I tested the fix:

  1. cloned the latest react-pts-canvas
  2. cloned the latest pts
  3. applied the fix in pts, then ran npm run build
  4. ran npm i in react-pts-canvas, copied over the dist from build into node_modules/pts, then ran npm run build
  5. ran npm i in the /example at react-pts-canvas, copied dist into example/node_modules/pts, then ran npm start

Further thoughts

I think pts would be simpler to maintain if using a mono repo for the core-lib (this repo) and all derivates (e.g. react). This would also be an opportunity to provide a consistent wording for the packages, e.g. @pts/core, @pts/react, etc. But those are just thoughts that I just wanted to share.

williamngan commented 1 year ago

Thank you so much @tom-bywild . This is such an amazing fix. Really appreciate your help on this.

And sorry for the late response - I forgot to check notifications :)

williamngan commented 1 year ago

And yes, I think we should probably move this to a monorepo, because I'm also working on a complementary library for Pts, so it'll be good to have everything in one place. Thanks again @tom-bywild !