-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable debug logs as soon as
__RX_PLAYER_DEBUG_MODE__
Today the `RX_PLAYER_DEBUG_MODE__` global boolean only enable debug logs if it is set **BEFORE** the RxPlayer files are evaluated / initially executed. This is difficult to explain to people not used to that kind of tricks. In this commit, I propose to perform an ugly `Object.defineProperty` trick on the global scope (`window` / `globalThis`) so we enable debug mode even if the RxPlayer was already imported. This way: 1. any application running with the RxPlayer could just at any time set something like `window.RX_PLAYER_DEBUG_MODE__ = true` in the console to obtain debug logs 2. [RxPaired](https://github.com/canalplus/RxPaired/)'s client script could be included in the console at any time without asking users to pass as argument the RxPlayer class if it's done at runtime. This can be seen as hacky and unusual, we would also mess ourselves with global scope which we usually don't like to do as a library. However reserving the `__RX_PLAYER_DEBUG_MODE__` global property and reacting on it still doesn't seems outlandish to me. --- Note that executing two times the RxPlayer files will make only the last one react to that property. I think this is not an issue because applications should never execute two times the same RxPlayer file in a given JavaScript realm (if it does, they rely on a bundler or user-agent not respecting ECMAScript's specification regarding module evaluation, so it's OK IMO to not support that case).
- Loading branch information
1 parent
a117437
commit 17fb6af
Showing
4 changed files
with
32 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters