Assets
Public API
WebIO.Asset — TypeAsset(url)
Asset(name, url)
Asset(name => url)
Asset(filetype, name, url)A browser asset that can be loaded by WebIO.
The url parameter may be either a remote URL or a local filepath (which will be served via AssetRegistry.jl). All of the following are valid url values.
https://unpkg.com/react@16/umd/react.development.js//unpkg.com/react@16/umd/react.development.js./path/to/foo.js
By default, the filetype is guessed as the extension of the specified url (only "js", "css", and "html" are currently supported) but may be specified if nonstandard extensions are in use.
WebIO.Async — TypeAsync(assets...)A group ("block") of assets that will be imported with no specified order (asynchronously) in the browser. This is useful when dependencies can be imported in any order. The elements of assets may either be Assets themselves, any valid constructor for an Asset, or a Sync or Async.
If the imports need to be imported sequentially, use Sync instead.
WebIO.Sync — TypeSync(assets...)A group ("block") of assets that will be imported sequentially (synchronously) in the browser. This is useful when dependencies have side effects that must be executed in order. The elements of assets may either be Assets themselves, any valid constructor for an Asset, or a Sync or Async.
If the imports do not need to be imported sequentially, use Async instead.
Examples
julia> WebIO.Sync(Asset("foo.js"), "bar" => "bar.js")
Sync(Asset[Asset("js", nothing, "foo.js"), Asset("js", "bar", "bar.js")])Private API
WebIO.dep2url — Functiondep2url(dep)Return the URL where the dependency can be fetched from. If the dependency is a URL (e.g. hosted at a CDN), the same URL is returned. Otherwise, the depency is registered with AssetRegistry.jl and served from there.
WebIO.ensure_asset — Functionensure_asset(asset)Ensure that asset is a valid Asset or Async or Sync. If it's not, calls the Asset constructor on the argument.
WebIO.getextension — Functiongetextension(path)Get the file extension of the path. The extension is defined to be the bit after the last dot, excluding any query string.
Examples
julia> WebIO.getextension("foo.bar.js")
"js"
julia> WebIO.getextension("https://my-cdn.net/foo.bar.css?version=1")
"css"WebIO.islocal — Functionislocal(path)Determine whether or not the specified path is a local filesystem path (and not a remote resource that is hosted on, for example, a CDN).
WebIO.path2url — Functionpath2url(path)Register the specified path with AssetRegistry and return the url that corresponds to that path.
Examples
julia> WebIO.path2url(expanduser("~/Documents/foo.js"))
"/assetserver/bd67c48cbe6388c22f85faef9840ff9a2dfc1df6-foo.js"