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

refactor!: split file handles into seperate function #126

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from

Conversation

jonkoops
Copy link
Collaborator

What kind of change does this PR introduce?

  • Bug Fix
  • Feature
  • Refactoring
  • Style
  • Build
  • Chore
  • Documentation
  • CI

Did you add tests for your changes?

  • Yes, my code is well tested
  • Not relevant

If relevant, did you update the documentation?

  • Yes, I've updated the documentation
  • Not relevant

Summary
Removes the handling of FileSystemFileHandle arrays from the fromEvent() function, and moves it to a dedicated fromFileHandles() function purposefully made for handling this data type. This reduces the need to handle polymorphic input and narrow down what the exact type should be in fromEvent(). Additionally, this allows bundlers to more effectively tree-shake the module in case the other code is never used. The JSDoc on the function itself has also been improved with additional details for the consumer.

Does this PR introduce a breaking change?
Yes, arrays of FileSystemFileHandle are now handled in a dedicated fromFileHandles() function. Users that were previously using fromEvent() will now have to use this dedicated function instead.

Other information
This also removes the notice that this feature is experimental, promoting fromFileHandles() to a stable API in the next major.

Signed-off-by: Jon Koops <[email protected]>

BREAKING CHANGE: Arrays of `FileSystemFileHandle` are now handled in a dedicated `fromFileHandles()` function.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 12412031215

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 12352595240: 0.0%
Covered Lines: 95
Relevant Lines: 95

💛 - Coveralls

@jonkoops jonkoops requested a review from rolandjitsu December 19, 2024 12:13
@jonkoops
Copy link
Collaborator Author

@rolandjitsu could I get your input on this PR? If you are enjoying the holidays don't worry, this can all certainly wait until next year.

@rolandjitsu
Copy link
Collaborator

@rolandjitsu could I get your input on this PR? If you are enjoying the holidays don't worry, this can all certainly wait until next year.

Sorry for the late reply. Gonna have a look at this now.

Comment on lines -26 to -30
} else if (
Array.isArray(evt) &&
evt.every((item) => "getFile" in item && typeof item.getFile === "function")
) {
return getFsHandleFiles(evt);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be a breaking change. I imagine it might affect quite a few downstream clients.

It would be good if the commit specifically mentions that (it's currently not explicit that fromEvent doesn't handle lists of file handles).

This will break the default behaviour of react-dropzone as well since it uses fromEvent as the default getFilesFromEvent .

Copy link
Collaborator

Choose a reason for hiding this comment

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

It might make sense to keep this func as it was and call the new func here to avoid breaking the behaviour of react-dropzone.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since we're already shipping several breaking changes on the beta branch I figure this is the best time to make any API changes.

It would be good if the commit specifically mentions that (it's currently not explicit that fromEvent doesn't handle lists of file handles).

Sure, how would you like me to do so? I can add this to the BREAKING CHANGE: section of the commit description, that should add it to the release notes. Additionally, I intend to write a migration guide for users after the dust has settled on the beta branch, which will likely be a little markdown document linked from the README.

WDYT?

@jonkoops jonkoops requested a review from rolandjitsu January 22, 2025 10:54
@jonkoops
Copy link
Collaborator Author

@rolandjitsu can we merge this one as-is, or would you like me to make further changes? I have some other work lined up that I'd like to get in as well.

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