Home Reference Source Test Repository
import EmbedEngine from 'url-embed/lib/classes/EmbedEngine.js'
public class | source

EmbedEngine

Resolves urls to embeds from a registered list of embed providers

Constructor Summary

Public Constructor
public

constructor(engineOptions: Object)

Member Summary

Public Members
public

Array of provider classes included in this library

public

The directory containing the default provider classes

public

Configuration options.

public

The registry of provider instances

public

providerSuperClasses: {URLEmbedProvider: URLEmbedProvider, OEmbedProvider: OEmbedProvider}

Utility references to provider superclasses

Method Summary

Public Methods
public

Returns error markup if there was no provider that matched the embedURL

public

filterData(data: {html: string})

Can be overridden/replaced to modify any provider's data before it is passed to the client callback.
Note: if you only need to modify a specific provider's data then there's a similar filterData method on each provider object, too.

public

getEmbed(embed: Embed, callback: function(embed: Embed))

Resolves an Embed object, populating its data property and calling the callback

public

getMultipleEmbeds(optArray: *, callback: *)

public

Registers all the default providers in this library

public

registerProvider(provider: URLProvider)

Registers a provider instance.

Public Constructors

public constructor(engineOptions: Object) source

Params:

NameTypeAttributeDescription
engineOptions Object
  • optional

configuration options

engineOptions.timeoutMs number
  • optional

request timeout in milliseconds

Public Members

public defaultProviderClasses: Array<URLEmbedProvider> source

Array of provider classes included in this library

public defaultProviderDirectory: String source

The directory containing the default provider classes

public engineOptions: Object source

Configuration options. These will also be passed to the configure method of each provider instance

Properties:

NameTypeAttributeDescription
engineOptions.timeoutMs number

request timeout in milliseconds

public providerRegistry: Array<URLEmbedProvider> source

The registry of provider instances

public providerSuperClasses: {URLEmbedProvider: URLEmbedProvider, OEmbedProvider: OEmbedProvider} source

Utility references to provider superclasses

Public Methods

public errorMarkupNoMatchingProvider(embed: Embed): * source

Returns error markup if there was no provider that matched the embedURL

Params:

NameTypeAttributeDescription
embed Embed

Embed object

Return:

*

public filterData(data: {html: string}) source

Can be overridden/replaced to modify any provider's data before it is passed to the client callback.
Note: if you only need to modify a specific provider's data then there's a similar filterData method on each provider object, too.

Params:

NameTypeAttributeDescription
data {html: string}

Data object containing embed html

public getEmbed(embed: Embed, callback: function(embed: Embed)) source

Resolves an Embed object, populating its data property and calling the callback

Params:

NameTypeAttributeDescription
embed Embed

Embed object

callback function(embed: Embed)

callback to invoke after resolving Embed

public getMultipleEmbeds(optArray: *, callback: *) source

Params:

NameTypeAttributeDescription
optArray *
callback *

public registerDefaultProviders(path: String) source

Registers all the default providers in this library

Params:

NameTypeAttributeDescription
path String
  • optional

directory of provider classes (if not specified it will default to the ones in this library)

public registerProvider(provider: URLProvider) source

Registers a provider instance.

Highlander Rule: this provider will replace an already registered provider if they have the same name property.

Params:

NameTypeAttributeDescription
provider URLProvider

instance of URLProvider or OEmbedProvider