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

Split contents of dom.js among four(4) files #7316

Merged
merged 7 commits into from
Oct 29, 2024

Conversation

SilasVM
Copy link
Contributor

@SilasVM SilasVM commented Oct 17, 2024

Resolves #7308

Changes:

Distributed the code within dom.js, across dom.js, p5.Element.js, p5.MediaElements.js, and p5.File.js.
Specific details of the split are detailed in Proposal #7308.

I've had trouble running the npm test command. I was unable to run it on a clean branch, so I don't think this is a direct indication of any issues with my changes. Please let me know if there's an alternate form of testing for this branch

I was also unsure of how to modify lines 13-19 of each file.

  • Should dom.js import each new file?
  • Do lines 13-16 need modification?

Screenshots of the change:

image

PR Checklist

Please let me know your thoughts @limzykenneth.

@davepagurek
Copy link
Contributor

Hey @SilasVM, what errors did you get when running npm run test?

@davepagurek
Copy link
Contributor

Do lines 13-16 need modification?

What you've got now looks good to me!

Should dom.js import each new file?

Currently the dom module is imported here, which we'll need to modify:

p5.js/src/app.js

Lines 42 to 43 in 39aab83

// DOM
import './dom/dom';

Other modules that we've refactored now export a function that gets called to set it up, e.g.:

p5.js/src/app.js

Lines 39 to 40 in 39aab83

import data from './data';
data(p5);

So we'll probably want to do that here too, following a similar pattern to other modules, which register an addon in their exported setup function, and then structure the implementation files like addons where we add properties to the fn parameter as a shortcut for adding to p5.prototype.

@SilasVM
Copy link
Contributor Author

SilasVM commented Oct 21, 2024

Hey @SilasVM, what errors did you get when running npm run test?

Thank you for taking a look and giving me the suggestion to modify app.js @davepagurek!

Currently I'm getting a lot of errors surrounding the DOM module. Some are saying "should be function" and it seems some of the methods aren't returning output as they should.
image

I modified app.js which reduced the amount of errors I was getting.] from 7 files and 93 failed tests to 5 files and 48 tests failed.
image

When running npm test on a clean fork of dev-2.0 I'm seeing 4 files and 10 test failed(I'd appreciate it if someone could test this as well to see if these failed tests are a result of a lacking dependency or some error occurring on my device):

clean_dev-2 0_npm_test

This is my output when running it on my pr fork after updating app.js, and the first screenshot in this comment is a more detailed look into what's failing:

pr_dev-2 0_npm_test_updated_app

I'm going to continue testing things out by modifying app.js, but I wanted to at least share what I've got so far.

@SilasVM
Copy link
Contributor Author

SilasVM commented Oct 22, 2024

Giving another update. I believe I resolved many of the issues. I implemented the index.js file within the dom folder. I modeled the files off of the data folder you mentioned.

My npm test now gives results equal to that of when I ran it on a clean fork. I'm still not sure if these errors I'm getting from the clean fork are a result of my device or not though.:
image

I'm now getting this issue when attempting to commit however:

image

…o adapt to refactored dom.js file. Also renamed non-class files to use lower case snake case file names.
@limzykenneth
Copy link
Member

@SilasVM For the linter error, please run npm run docs first and that should clear it. I'll check the tests.

@SilasVM
Copy link
Contributor Author

SilasVM commented Oct 22, 2024

Thank you @limzykenneth, the error was cleared.

npm test now displays all clear tests within the DOM module:
image

These are the remaining error spots from npm test:
image

More detailed looks at the first 3 files:

image
The 4th file:

image

@limzykenneth
Copy link
Member

CI tests are passing so that's fine for now, those failing are visual tests so probably related to some threshold we can tweak later.

src/app.js Outdated Show resolved Hide resolved
src/app.js Outdated Show resolved Hide resolved
src/dom/index.js Outdated Show resolved Hide resolved
SilasVM and others added 3 commits October 23, 2024 17:58
Fixed indentation on affected lines.

Co-authored-by: Kenneth Lim <hello@limzykenneth.com>
Removed redundant code in app.js.

Co-authored-by: Kenneth Lim <hello@limzykenneth.com>
Amended capitalization of DOM to dom.

Co-authored-by: Kenneth Lim <hello@limzykenneth.com>
@SilasVM
Copy link
Contributor Author

SilasVM commented Oct 23, 2024

@limzykenneth, when I was implementing your requests, I noticed the following files have this unnecessary line of code: import p5 from '../core/main';.
image

I removed the line in each of the 4 files, ran npm test, and everything in DOM passes as it should with no new test failures. I have the branch ready to push, would you advise leaving this line in any of the files for any reason or should I go ahead and update the PR with this modification?

@limzykenneth
Copy link
Member

Yes these are not typically necessary with the new module syntax.

@limzykenneth limzykenneth merged commit 82ac2af into processing:dev-2.0 Oct 29, 2024
2 checks passed
@limzykenneth
Copy link
Member

@SilasVM Looks good. Thanks!

@SilasVM
Copy link
Contributor Author

SilasVM commented Oct 29, 2024

Thank you @limzykenneth and @Qianqianye for this opportunity and your assistance throughout!

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.

3 participants