apache / apache/cordova-plugin-file
Do not overwrite standard File API
- Dominant language
- JavaScript
- Stars
- 744
- Forks
- 754
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 1
Description
# Feature Request
## Motivation Behind Feature
This plugin overwrites standard Web API implementations like:
| Plugin Clobber | Standard Web API |
| -------------------- | ------------------------- |
| [`window.File`](https://github.com/apache/cordova-plugin-file/blob/rel/6.0.1/plugin.xml#L49) | [File](https://developer.mozilla.org/en-US/docs/Web/API/File) |
| [`window.FileReader`](https://github.com/apache/cordova-plugin-file/blob/rel/6.0.1/plugin.xml#L61) | [FileReader](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) |
| [`window.ProgressEvent`](https://github.com/apache/cordova-plugin-file/blob/rel/6.0.1/plugin.xml#L96) | [ProgressEvent](https://developer.mozilla.org/en-US/docs/Web/API/ProgressEvent) |
This causes issues for example with the E2E testing tool Cypress. Specifically the Cypress plugin [`cypress-file-upload`](https://github.com/abramenal/cypress-file-upload/issues/71#issuecomment-493975216), which relies on the default File API implementation.
## Feature Description
Do not overwrite the standard API. It seems that the plugin itself using it's own `require` method to include the correct JS file. But the `plugin.xml` file also overwrites the standard Web implementation.
Drawbacks would be that people that are using these exposed overwritten API's would have a problem or need to re-write code. That being said, the adjusted File API that this plugin needs could still be exposed on the window object, but not overwrite the standard API, for example in an own namespace or something like that.
For example expose:
* `window.File` within a `cordova` namespace, like `window.cordova.File`
## Alternatives or Workarounds
Alternatives would be that tools like Cypress or any other codebase that needs the standard API include a polyfill to get the standard API back again.
Contributor guide
Research direction
Inspect plugin.xml entries for window.File, window.FileReader, and window.ProgressEvent, then trace the plugin's require path for its JavaScript implementation. Define how the adjusted APIs should be exposed without replacing standard Web APIs, while considering compatibility for existing users and validating the Cypress-related behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100