trucks-resolver-core v1.0.1
Resolver
Abstract HTML import resolver
Implementation contract for protocol resolver plugins.
Install
npm i trucks-resolver-core --saveUsage
Resolver plugin implementations should extend this class, see the file and http plugins for example implementations.
API
Resolver
Abstract protocol resolver.
Resolver plugin implementations should create a subclass of this class and
invoke registry.register() with a protocol and the derived class.
Resolver
public Resolver(state, href[, parent])Create a resolver.
The file property is initialized to the canonical path for
the href argument.
stateObject compiler state.hrefString source URL to resolve.parentObject a parent resolver.
Throws
TypeErrorattempting to parse a bad href argument.
protocol
String protocolGet the protocol from the href assigned to this
resolver, if no protocol is found lookup is performed
in a parent hierarchy.
file
String fileAbsolute computed path for the URL.
This is initialized to the canonical path for the href argument
passed to the constructor but implementations may overwrite this.
resolve
public resolve(cb)Resolve the contents for the URL.
Implementors should invoke callback with an error and Buffer contents
or an object representing compiler options:
(err, contents) => {}.
When the callback is invoked with compiler options it is treated as a
nested compile pass using the given options which should have an input
files array.
cbFunction callback function.
getCanonicalPath
public getCanonicalPath()Get a canonical path for the URL, used to determine if the resource has already been processed.
Typically implementors would convert this to an absolute path or absolute URL to ensure that duplicates can be resolved.
Returns the canonical file path to resolve.
License
MIT
Created by mkdoc on August 2, 2016