Used internally. Use the static methods on this class to create new EpubOcfResourceProvider instances.
Returns true if this resource provider accepts the given URL. Whether the URL is accepted or not is implementation specific. It could for example be that the specified URL must be relative to the Base URL, or that the protocol used is http. Note that this is not an "exists" check, calling fetch() with the given URL can still fail even if this method returns true.
If this method returns false, the fetch() method will fail with the specified URL.
Unloads all loaded EpubPublications, releasing any used resources.
Note: If ReaderPublications have been loaded using Publications from this instance, You must call readingSystemEngine.unloadPublication() or readingSystemEngine.destroy() before calling this method.
Disables the Colibrio implementation of the EPUB Open Container Format specification's Resource Obfuscation Algorithm (https://www.w3.org/publishing/epub3/epub-ocf.html#sec-resource-obfuscation). To support obfuscated resources, such as fonts, you need to add your own implementation and add it using the DrmManager.addEncryptionMethod method.
Enables the Colibrio implementation of the EPUB Open Container Format specification's Resource Obfuscation Algorithm (https://www.w3.org/publishing/epub3/epub-ocf.html#sec-resource-obfuscation). If you choose to disable this feature, you need to add your own implementation and add it using the DrmManager.addEncryptionMethod method.
Starts fetching a resource from this ResourceProvider. The returned Promise is resolved once a successful response is available.
The response includes both the metadata for the resource and methods for reading the resource body.
If a relative URL is specified, it will be resolved against the base URL of this ResourceProvider. If this ResourceProvider does not have a base URL, relative URLs will cause the returned Promise to be rejected.
Contrary to the browser Fetch API, this method MUST reject the returned Promise if the request is non-successful, such as if the resource could not be found.
The options
parameter can be used to configure how the resource should be fetched.
If the options
parameter is not defined, the fetch is performed using the default values specified in IResourceRequestOptions.
Fetches metadata about a resource using the specified URL.
If a relative URL is specified, it will be resolved against the base URL of this ResourceProvider. If this ResourceProvider does not have a base URL, relative URLs will cause the returned Promise to be rejected.
The options
parameter can be used to configure the request.
If the options
parameter is not defined, the request is performed using the default values specified in IResourceRequestOptions.
Get the base URL for this ResourceProvider, if available. Relative URLs passed to fetch() or fetchMetadata() will be resolved using this base URL. The path component of the base URL SHOULD end with a forward slash.
If null is returned, relative URLs cannot be used with fetch() or fetchMetadata().
An OCF container can host multiple EPUB publications. This method returns the default publication in the OCF which is the first one defined in the container.xml file.
The DrmManager instance used for decrypting encrypted resources.
Get the mime-type of the EPUB OCF Container
Get all EPUB publication instances defined in the OCF container.xml file. The first item in the array is the default EPUB publication for the OCF according to the specification.
Get a list of ResourceMetadata items for all resources that can be fetched from this ResourceProvider instance. Returns null if this resource provider does not have a resource manifest.
For example, the ZipResourceProvider has a central directory containing metadata about all resources within the zip file, and would therefore return a resource manifest.
As another example, An HttpResourceProvider can probably not know about all available resources and should therefore return null.
If destroy() has been called on this instance.
Returns true if acceptsUrl() returns true for the URL, and the URL can be used by the browser directly without being fetched from the ResourceProvider.
For example: If true is returned, the URL can be assigned to the src
attributes of ,
Returns false otherwise.
Creates a new EpubOcfResourceProvider using the specified ArrayBuffer containing the .epub file data.
Publication resources are extracted from the EPUB container using a WebWorker. If transfer is set to true, the ArrayBuffer is transferred to the WebWorker which will improve performance when loading the zip archive. See https://developer.mozilla.org/en-US/docs/Web/API/Transferable
Encrypted resources within the EPUB container can be decrypted by configuring a DrmManager
.
If the EpubOcfResourceProvider is created successfully, you can use getDefaultPublication() method to get a Publication instance which
can then be loaded into the ReadingSystemEngine using loadPublication()
.
The complete EPUB file as an ArrayBuffer.
If true, transfers the ArrayBuffer to the WebWorker instance.
The DrmManager to use for this epub file. If omitted, a new DrmManager will be created with this instance.
Resolved with an IEpubOcfResourceProvider instance if the EPUB file was loaded successfully.
Creates a new EpubOcfResourceProvider using the another ResourceProvider as source. In this case the specified backing ResourceProvider will be used to fetch publication resources instead of extracting them from an .epub file. This allows you for example to load resource form disk or from an HTTP endpoint where the EPUB container has already been extracted.
Encrypted resources within the EPUB can be decrypted by configuring a DrmManager
.
If the EpubOcfResourceProvider is created successfully, you can use getDefaultPublication() method to get a Publication instance which
can then be loaded into the ReadingSystemEngine using loadPublication()
.
The resource provider where the EPUB resources can be found.
Used for calculating the publications hashSignature and ultimately the default defaultLocatorUrl
in EpubReaderPublication.
The DrmManager to use for this EPUB. If omitted, a new DrmManager will be created with this instance.
Callback used when this resource provider is destroyed.
Resolved with an EpubOcfResourceProvider instance if the EPUB was loaded successfully.
Creates a new EpubOcfResourceProvider using the specified base64 encoded string containing the .epub file data.
Encrypted resources within the EPUB container can be decrypted by configuring a DrmManager
.
If the EpubOcfResourceProvider is created successfully, you can use getDefaultPublication() method to get a Publication instance which
can then be loaded into the ReadingSystemEngine using loadPublication()
.
The complete EPUB file as a base64 encoded string.
The DrmManager to use for this epub file. If omitted, a new DrmManager will be created with this instance.
Resolved with an IEpubOcfResourceProvider instance if the EPUB file was loaded successfully.
Creates a new EpubOcfResourceProvider using the specified Blob containing the .epub file data.
Encrypted resources within the EPUB container can be decrypted by configuring a DrmManager
.
If the EpubOcfResourceProvider is created successfully, you can use getDefaultPublication() method to get a Publication instance which
can then be loaded into the ReadingSystemEngine using loadPublication()
.
The complete EPUB file as a Blob.
The DrmManager to use for this epub file. If omitted, a new DrmManager will be created with this instance.
Resolved with an IEpubOcfResourceProvider instance if the EPUB file was loaded successfully.
Creates a new EpubOcfResourceProvider using the specified IRandomAccessDataSource containing the .epub file data.
When loading an EPUB container using this method, the EPUB file is streamed in chunks from IRandomAccessDataSource. Using this method, the framework will download only the requested portions of the publication, thus minimizing load times and data usage.
Publication resources are extracted from the EPUB container using a WebWorker.
If options.transferBuffers
is set to true, the resulting ArrayBuffers from calling IRandomAccessDataSource.fetchChunk()
are transferred to the WebWorker. This will improve performance when extracting resource data from the EPUB.
See https://developer.mozilla.org/en-US/docs/Web/API/Transferable
Encrypted resources within the EPUB container can be decrypted by configuring a DrmManager
.
If the EpubOcfResourceProvider is created successfully, you can use getDefaultPublication() method to get a Publication instance which
can then be loaded into the ReadingSystemEngine using loadPublication()
.
The instance where chunks of zip data can be fetched.
The DrmManager to use for this epub file. If omitted, a new DrmManager will be created with this instance.
Configures how the underlying ZipResourceProvider will fetch data from dataSource.
Generated using TypeDoc
Use the static methods in this class to create EpubOcfResourceProviders that are used for accessing the EPUB publications and their resources.
An file with a .epub extension is really a so called OCF container. The actual EPUB publication is contained in the OCF container. The OCF also specifies all encrypted resources within the container (see encryption.xml file). See EPUB Open Container Format (OCF): https://www.w3.org/publishing/epub3/epub-ocf.htm
Resources that are encrypted are decrypted using the DrmManager before it is returned. By default, the EpubOcfResourceProvider has support for the Resource Obfuscation Algorithm (https://www.w3.org/publishing/epub3/epub-ocf.html#sec-resource-obfuscation). In order to facilitate decryption for other algorithms you must provide the DrmManager with matching EncryptionMethod implementations.
See DrmManager for more information.