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

Removed private methods of plugins and generalized plugins' access #1928

Merged
merged 33 commits into from
May 4, 2020

Conversation

marizuccara
Copy link
Contributor

Short description of changes:

Removed all private methods of plugin classes, so the plugins can be extended avoiding duplicated code, because private methods can not be inherited.

Allow to extend also the Region class, introducing the possibility to create your RegionCustom class that extends the basic one, overriding its methods if necessary.

Generalized access to plugins object: in some plugin classes, the access to their own params was made from the outside. For example, to access to the timeline plugin duration parameter, the access was done in this way:

this.wavesurfer.timeline.params.duration
instead of:
this.params.duration.

Accessing this parameter from the outside made it impossible to call custom plugins with custom names, because to the wavesurfer object is assigned a plugin with the name you give it. So, if you for example call it timelineCustom, the access to the duration parameter from the outside, should be instead this.wavesurfer.timelineCustom.params.duration. But in this way you cannot generalize the plugin class.

Breaking changes in the internal API:

  • Removed private methods from the cursor.js and timeline.js files.

  • In the timeline plugin, access to the duration parameter from its params object.

  • Added export clause to the Region class, so it can be also extended.

  • Access to the getRegionSnapToGridValue method of the regions plugin from the internal util object, instead of from the outside.

  • Pass to the Region class constructor, the util object of the RegionsPlugin class, so the getRegionSnapToGridValue method have not be accessed from outside.

Related Issues and other PRs:

Issue #1914
PR #1921

marizuccara and others added 29 commits October 7, 2019 13:00
… HTML5 audio tag and use it with WebAudio features.
- Put the possibility of handle audio tag with API Web Audio directly in the MediaElement backend, setting a new wavesurfer boolean parameter, 'mediaElementWebAudio', to true.
- fixed version number and switch-case
- added the possibility to inherit also the Region class
- generalized access to wavesurfer's plugins properties, so the custom plugins can be defined with custom names
@coveralls
Copy link

coveralls commented Apr 26, 2020

Coverage Status

Coverage remained the same at 80.62% when pulling 7785908 on marizuccara:no-private-plugins into d8f5c32 on katspaugh:master.

@marizuccara
Copy link
Contributor Author

marizuccara commented Apr 29, 2020

Another thing. The Region class can be moved to a separate file? This is because if we export both Region and RegionsPlugin class, we have errors when trying to create the plugin in this way:

Wavesurfer['regions'].create(options)

bacause `Wavesurfer['regions']' give this:

image

so create method cannot be accessed directly, as when creating the plugin in this way:

RegionsPlugin.create(options)

@thijstriemstra
Copy link
Contributor

thijstriemstra commented Apr 29, 2020

Another thing. The Region class can be moved to a separate file?

If we do that I would place the plugin files in it's own directory, e.g. src/plugin/regions/. This has implications for the build process but shouldn't be too hard to fix.

Splitting into multiple files/classes would be useful for the other larger plugins as well.

And can you also add a changelog entry?

marizuccara added 2 commits May 3, 2020 13:31
- Region class and RegionsPlugin class moved in plugin/regions
- modified the building plugins procedure to find recursively plugins in directories
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.

None yet

4 participants