Skip to content

Commit

Permalink
OffscreenCanvas: add typeof check. Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alemart committed Dec 11, 2023
1 parent 38641df commit a86aa7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ A `SpeedyMedia` object encapsulates a media object: an image, a video, a canvas

##### Speedy.load()

`Speedy.load(source: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap, options?: object): SpeedyPromise<SpeedyMedia>`
`Speedy.load(source: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, options?: object): SpeedyPromise<SpeedyMedia>`

Tells Speedy to load `source`. The `source` parameter may be an image, a video, a canvas or a bitmap.

###### Arguments

* `source: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap`. The media source.
* `source: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap`. The media source.
* `options: object, optional`. Additional options for advanced configuration. See [SpeedyMedia.options](#speedymediaoptions) for details.

###### Returns
Expand Down Expand Up @@ -319,7 +319,7 @@ Returns `null`.

##### SpeedyMedia.source

`SpeedyMedia.source: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap, read-only`
`SpeedyMedia.source: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, read-only`

The media source associated with the `SpeedyMedia` object.

Expand Down
4 changes: 2 additions & 2 deletions src/core/speedy-media-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { SpeedyPromise } from './speedy-promise';
import { AbstractMethodError, IllegalArgumentError, IllegalOperationError, TimeoutError, ResourceNotLoadedError } from '../utils/errors';
import { MediaType } from '../utils/types'

/** @typedef {HTMLImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap} SpeedyMediaSourceNativeElement */
/** @typedef {HTMLImageElement|HTMLVideoElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} SpeedyMediaSourceNativeElement */

/** Internal token for protected constructors */
const PRIVATE_TOKEN = Symbol();
Expand Down Expand Up @@ -64,7 +64,7 @@ export class SpeedyMediaSource
return SpeedyVideoMediaSource.load(wrappedObject);
else if(wrappedObject instanceof HTMLCanvasElement)
return SpeedyCanvasMediaSource.load(wrappedObject);
else if(wrappedObject instanceof OffscreenCanvas)
else if(typeof OffscreenCanvas !== 'undefined' && wrappedObject instanceof OffscreenCanvas)
return SpeedyOffscreenCanvasMediaSource.load(wrappedObject);
else if(wrappedObject instanceof ImageBitmap)
return SpeedyBitmapMediaSource.load(wrappedObject);
Expand Down

0 comments on commit a86aa7c

Please sign in to comment.