Skip to content

Conversation

jamesrweb
Copy link
Member

@jamesrweb jamesrweb commented Aug 16, 2025

Related Issue

N / A

PR Type

  • πŸ› Bug Fix
  • ✨ New Feature
  • πŸ”¨ Code Refactor
  • πŸ“ Documentation Update
  • πŸ§ͺ Test Update
  • πŸ”§ Build/CI Update
  • 🧹 Chore
  • βͺ Revert

Description

This PR allows the usage of p5 v2.x.x within the wrapper and is being done as part of the preparations for the upcoming v5.x.x release.

Proposed Changes

  • Update the p5 peer dependency to the v2.x.x range
  • Update the source code and tests to support the new p5 version
  • Update the project documentation to inform people of the upcoming p5 version 2.x.x changes
  • Add an example to the demo application of using async / await in the setup method

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing (please describe)

Tested the demo application locally and checked all sketches still run as expected. Also ran the test suite and all existing tests pass without changes.

Screenshots/Recordings

I can recommend checking out the live stream from Dan and Kit. It is not required to review this but might be of interest for you to see some of the p5 v2.x.x changes. In saying that most of the topics covered are surface level BUT for a deeper dive they have some beta docs you can check if interested also.

p5.js 2.0 with Kit Kuksenok

Breaking Changes

  • Yes (please describe)
  • No

Since p5 v2.x.x now have some methods converted for use with async / await such as loadFont, etc, this will inherintly be a breaking change for consumers of the wrapper but it is from the side of p5 itself and makes sense since this is a major change on their side.

Checklist

  • My code follows the code style of this project
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • My changes generate no new warnings

Additional Notes

Please test thoroughly @yevdyko, perhaps in one of your personal projects like you usually do and maybe we can use your experience in the 5.x.x release notes to help people navigate some of the changes to the p5 methods, etc, WDYT?

@jamesrweb jamesrweb self-assigned this Aug 16, 2025
@jamesrweb jamesrweb requested a review from yevdyko as a code owner August 16, 2025 21:26
@jamesrweb jamesrweb added enhancement dependencies Pull requests that update a dependency file security This label applies to security issues documentation Pull requests that update project documentation labels Aug 16, 2025
Copy link

github-actions bot commented Aug 16, 2025

Coverage report for commit: 2078d84
File: ./coverage/clover.xml

Cover β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” Freq.
   0% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  10% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  20% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  30% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  40% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  50% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  60% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  70% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  80% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
  90% β”‚ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚  0.0%
 100% β”‚ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚ 100.0%
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 *Legend:* β–ˆ = Current Distribution 
Summary - Lines: 100.00% | Methods: 100.00% | Branches: 91.30%
FilesLinesMethodsBranches
src/components
Β  Β ReactP5Wrapper.tsx100.00%100.00%100.00%
Β  Β ReactP5WrapperGuard.tsx100.00%100.00%72.73%
Β  Β ReactP5WrapperWithSketch.tsx100.00%100.00%88.89%
src/constants
Β  Β P5WrapperClassName.ts100.00%100.00%100.00%
src/contracts
Β  Β CanvasInstanceRef.ts100.00%100.00%100.00%
Β  Β InputProps.ts100.00%100.00%100.00%
Β  Β P5CanvasInstance.ts100.00%100.00%100.00%
Β  Β P5WrapperProps.ts100.00%100.00%100.00%
Β  Β P5WrapperPropsWithSketch.ts100.00%100.00%100.00%
Β  Β Sketch.ts100.00%100.00%100.00%
Β  Β SketchProps.ts100.00%100.00%100.00%
Β  Β WithChildren.ts100.00%100.00%100.00%
Β  Β Wrapper.ts100.00%100.00%100.00%
Β  Β WrapperRef.ts100.00%100.00%100.00%
Β  Β p5.ts100.00%100.00%100.00%
src
Β  Β main.tsx100.00%100.00%100.00%
src/utils
Β  Β createCanvasInstance.ts100.00%100.00%100.00%
Β  Β logErrorBoundaryError.ts100.00%100.00%100.00%
Β  Β propsAreEqual.ts100.00%100.00%100.00%
Β  Β removeCanvasInstance.ts100.00%100.00%100.00%
Β  Β updateCanvasInstance.ts100.00%100.00%100.00%
Β  Β withoutKeys.ts100.00%100.00%100.00%

πŸ€– comment via lucassabreu/comment-coverage-clover

@jamesrweb jamesrweb enabled auto-merge August 16, 2025 23:19
Copy link
Contributor

@yevdyko yevdyko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesrweb I tested the changes locally, and everything works as expected πŸš€

Regarding adding extra notes to the README, I don’t think it’s necessary since the component name and interface remain the same except that React needs to be updated to version 19 and all breaking changes in p5 version 2 must be addressed before using this version 5 component.

I was wondering about the P5 2.0 support changes, as I only noticed updates in the import and configuration files. Am I missing anything?

P.S. Are you considering renaming the component in version 6 from ReactP5Wrapper to P5Canvas? This would make its purpose immediately clear, improve readability, and align with common naming conventions by emphasizing what it actually renders. WDYT?

@jamesrweb jamesrweb added this pull request to the merge queue Aug 18, 2025
@yevdyko
Copy link
Contributor

yevdyko commented Aug 18, 2025

Btw @jamesrweb should we add a new version such as 5.0.0-rc.4?

@jamesrweb
Copy link
Member Author

@jamesrweb I tested the changes locally, and everything works as expected πŸš€

Nice πŸš€

Regarding adding extra notes to the README, I don’t think it’s necessary since the component name and interface remain the same except that React needs to be updated to version 19 and all breaking changes in p5 version 2 must be addressed before using this version 5 component.

Makes sense πŸ‘πŸ»

I was wondering about the P5 2.0 support changes, as I only noticed updates in the import and configuration files. Am I missing anything?

They did a whole load of changes to how plugins work, async / await support, new methods for shaders, changes to methods like vertex and a whole load of other things. The types are sadly not so good FYI so typescript users will maybe hit some issues but they will work on this in coming releases they said.

P.S. Are you considering renaming the component in version 6 from ReactP5Wrapper to P5Canvas? This would make its purpose immediately clear, improve readability, and align with common naming conventions by emphasizing what it actually renders. WDYT?

Could do but I would make a separate PR for this, can you do that?

@jamesrweb
Copy link
Member Author

jamesrweb commented Aug 18, 2025

Btw @jamesrweb should we add a new version such as 5.0.0-rc.4?

I will do later tonight as a separate commit.

Done. 🚒

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 18, 2025
@jamesrweb jamesrweb merged commit 8c2a1a1 into master Aug 18, 2025
10 checks passed
@jamesrweb jamesrweb deleted the p5-2.x.x branch August 18, 2025 13:10
@yevdyko
Copy link
Contributor

yevdyko commented Aug 18, 2025

@jamesrweb Yeah, I saw the list of changes. As I understand it, types are a weak point of the package for those who use it with TypeScript, as you mentioned in your comment on the code

@yevdyko
Copy link
Contributor

yevdyko commented Aug 18, 2025

@jamesrweb Tested 5.0.0-rc.4 and it looks good πŸ’ͺ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file documentation Pull requests that update project documentation enhancement security This label applies to security issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants