20 lines
688 B
JavaScript
20 lines
688 B
JavaScript
"use strict";
|
|
|
|
function resolveAsset(manifestUrl, manifest, id = "main") {
|
|
const asset = manifest.assets.find((candidate) => candidate.id === id);
|
|
if (!asset) throw new Error(`Unknown asset '${id}'`);
|
|
return new URL(asset.uri, manifestUrl).href;
|
|
}
|
|
|
|
function resolveRuntime(manifestUrl, manifest, id) {
|
|
const runtime = (manifest.runtime || []).find((candidate) => candidate.id === id);
|
|
if (!runtime) throw new Error(`Unknown runtime asset '${id}'`);
|
|
return new URL(runtime.uri, manifestUrl).href;
|
|
}
|
|
|
|
function placement(manifest) {
|
|
return { ...manifest.placement, coordinateSystem: manifest.coordinateSystem };
|
|
}
|
|
|
|
module.exports = { resolveAsset, resolveRuntime, placement };
|