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

feat: Put custom event definitions in class #7640

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

avelad
Copy link
Member

@avelad avelad commented Nov 20, 2024

Close #1564

@avelad avelad marked this pull request as draft November 20, 2024 13:58
* specific error that occurred. In an uncompiled build, you can also use the
* <code>message</code> and <code>stack</code> properties to debug.
* @extends {shaka.util.FakeEvent}
* @exportDoc
Copy link
Member

Choose a reason for hiding this comment

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

Not sure, but should this be @export so it can be called by apps?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I change to @export the documentation is not generated correctly.... I don't know why...

lib/player.js Outdated
@@ -35,6 +35,7 @@ goog.require('shaka.media.StreamingEngine');
goog.require('shaka.media.TimeRangesUtils');
goog.require('shaka.net.NetworkingEngine');
goog.require('shaka.net.NetworkingUtils');
goog.require('shaka.Player.ErrorEvent');
Copy link
Member

Choose a reason for hiding this comment

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

I think the errors are caused by ordering and namespaces here. goog.require here will assign the ErrorEvent class to shaka.Player.ErrorEvent. Later in this file, we assign shaka.Player = class ..., overwriting what was assigned to ErrorEvent by replacing the whole shaka.Player namespace.

So we might need to do something like this:

  1. Rename shaka.Player.ErrorEvent to shaka.errors.ErrorEvent, giving errors their own namespace
  2. For backward compatibility, assign shaka.Player.ErrorEvent = shaka.errors.ErrorEvent after the definition of shaka.Player
  3. Actually, no need for backward compatibility. That class never existed at runtime, and was also never in our externs. It only ever existed as a doc, so it's fine to rename it AFAICT. But the new name should be exported so it's in the generated externs/defs, where other projects can refer to it as a strong type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, but I used shaka.events.ErrorEvent instead

@avelad avelad added type: enhancement New feature or request priority: P3 Useful but not urgent labels Dec 5, 2024
@avelad avelad added this to the v4.13 milestone Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: P3 Useful but not urgent type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Put custom event definitions into externs
2 participants