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
Fix isSupported
check in browsers missing SourceBuffer
global
#2490
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/is-supported.ts
Outdated
@@ -5,7 +5,7 @@ export function isSupported (): boolean { | |||
if (!mediaSource) { | |||
return false; | |||
} | |||
const sourceBuffer = SourceBuffer || (window as any).WebKitSourceBuffer; | |||
const sourceBuffer = (self as any).SourceBuffer || (self as any).WebKitSourceBuffer as SourceBuffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const sourceBuffer = (self as any).SourceBuffer || (self as any).WebKitSourceBuffer as SourceBuffer; | |
const sourceBuffer = self.SourceBuffer || (self as any).WebKitSourceBuffer as SourceBuffer; |
self.SourceBuffer
already has the correct type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires a TypeScript update (done 2c4f7e6). I was getting this error and went for the easy fix instead of updating deps.
$ npm run type-check
> tsc --noEmit
src/is-supported.ts:8:29 - error TS2339: Property 'SourceBuffer' does not exist on type 'Window'.
8 const sourceBuffer = self.SourceBuffer || (self as any).WebKitSourceBuffer as SourceBuffer;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh maybe. I just checked locally in vscode and it had the types. If it doesn’t cause any issues I think keeping typescript up to date makes sense
@@ -76,6 +76,13 @@ module.exports = { | |||
'never' | |||
], | |||
|
|||
'no-restricted-globals': [2, | |||
{ | |||
'name': 'SourceBuffer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR will...
isSupported
check in browsers missingSourceBuffer
global.SourceBuffer
global usage.npm audit fix
Why is this Pull Request needed?
JavaScript... no exceptions.
Are there any points in the code the reviewer needs to double check?
No
Resolves issues:
resolves #2430
resolves #2476
Checklist