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

Updates, NPM, and Instance Mode #26

Open
jackwh opened this issue Apr 18, 2023 · 5 comments
Open

Updates, NPM, and Instance Mode #26

jackwh opened this issue Apr 18, 2023 · 5 comments

Comments

@jackwh
Copy link

jackwh commented Apr 18, 2023

Hi! 👋 Is this library still maintained? I've been unable to import it (cleanly, anyway) into a Yarn/TypeScript project, as no package is published on npm.

Furthermore, when I tried to copy the source code in manually, I couldn't get it to work with p5's Instance Mode. The library seems to assume p5 is always available globally, which is rarely the case in modern JS projects.

Thanks!

@jwdunn1
Copy link
Member

jwdunn1 commented Apr 18, 2023

Yes, this library in maintained. 1) Coincidentally, a new NPM package was published this morning. 2) The TypeScript issue #13 is still under review with a testable version merged into the repo (after the npm package was published). 3) Yes, p5.EasyCam works in instance mode: example 1 example 2

@jackwh
Copy link
Author

jackwh commented Apr 19, 2023

Thanks @jwdunn1 for the speedy reply 👍 The instance mode issue is a little different, I've added some clarification below.

The npm package doesn't export any methods, so it can't be imported as a module. Instead the plugin has to be loaded into the global scope. In instance mode p5 won't always be available in the global scope, and the p5 class also might be imported under an alias.

These lines seem to be causing the problem. They assume a p5 variable is available at runtime. Even if the p5 runtime is loaded and available, hard-coding onto the p5.prototype prevents using this plugin in a class which has a p5 instance assigned to a property. More info here.

If you'd welcome a PR for this, I can have a go at it! 😊

@jwdunn1
Copy link
Member

jwdunn1 commented Apr 19, 2023

Fascinating! Thanks for your insights. Yes, contributions are welcome!

@jackwh
Copy link
Author

jackwh commented Apr 20, 2023

I got a prototype working last night, just need to make sure it stays backwards-compatible in the global context. Will get a PR up when I get some time to come back to this over the next few days. Thanks!

@jwdunn1
Copy link
Member

jwdunn1 commented Apr 30, 2023

@jackwh Were you able to import the modified version (from the PR) successfully into your Yarn/TypeScript project?

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

No branches or pull requests

2 participants