UNPKG

esri-loader

Version:

A tiny library to help load ArcGIS API for JavaScript modules in non-Dojo applications

43 lines (42 loc) 1.41 kB
/* Copyright (c) 2022 Environmental Systems Research Institute, Inc. * Apache-2.0 */ var DEFAULT_VERSION = '4.25'; var NEXT = 'next'; export function parseVersion(version) { if (version.toLowerCase() === NEXT) { return NEXT; } var match = version && version.match(/^(\d)\.(\d+)/); return match && { major: parseInt(match[1], 10), minor: parseInt(match[2], 10) }; } /** * Get the CDN url for a given version * * @param version Ex: '4.25' or '3.42'. Defaults to the latest 4.x version. */ export function getCdnUrl(version) { if (version === void 0) { version = DEFAULT_VERSION; } return "https://js.arcgis.com/".concat(version, "/"); } /** * Get the CDN url for a the CSS for a given version and/or theme * * @param version Ex: '4.25', '3.42', or 'next'. Defaults to the latest 4.x version. */ export function getCdnCssUrl(version) { if (version === void 0) { version = DEFAULT_VERSION; } var baseUrl = getCdnUrl(version); var parsedVersion = parseVersion(version); if (parsedVersion !== NEXT && parsedVersion.major === 3) { // NOTE: at 3.11 the CSS moved from the /js folder to the root var path = parsedVersion.minor <= 10 ? 'js/' : ''; return "".concat(baseUrl).concat(path, "esri/css/esri.css"); } else { // assume 4.x return "".concat(baseUrl, "esri/themes/light/main.css"); } }