@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
61 lines • 2.31 kB
JavaScript
import _includesInstanceProperty from "core-js-pure/stable/instance/includes.js";
import _pushInstanceProperty from "core-js-pure/stable/instance/push.js";
import { getVersion, getSha, getBuildDate } from "./build-info/BuildInfo.js";
import { runCssVersionMismatchWarning } from "./helpers/runCssVersionMismatchWarning.js";
import { runOldBuildDateWarning } from "./helpers/runOldBuildDateWarning.js";
export const version = getVersion();
export const sha = getSha();
export const buildDate = getBuildDate();
export function init() {
if (typeof window !== 'undefined') {
class Eufemia {
constructor() {
var _context, _context3;
if (!window.__eufemiaVersions) {
window.__eufemiaVersions = [];
}
if (!_includesInstanceProperty(_context = window.__eufemiaVersions).call(_context, this.version)) {
var _context2;
_pushInstanceProperty(_context2 = window.__eufemiaVersions).call(_context2, this.version);
}
if (!window.__eufemiaSHAs) {
window.__eufemiaSHAs = [];
}
if (!_includesInstanceProperty(_context3 = window.__eufemiaSHAs).call(_context3, this.sha)) {
var _context4;
_pushInstanceProperty(_context4 = window.__eufemiaSHAs).call(_context4, this.sha);
}
}
get version() {
return version;
}
get sha() {
return sha;
}
get buildDate() {
return buildDate;
}
get shas() {
return window.__eufemiaSHAs;
}
get versions() {
return window.__eufemiaSHAs.map((sha, i) => {
const scopeElement = document.querySelector(`[data-scope-hash-id][data-scope-sha="${sha}"]`);
const styleElement = scopeElement?.querySelector('.dnb-core-style');
const css = window.getComputedStyle(styleElement || document.body).getPropertyValue('--eufemia-version').replace(/"/g, '').replace(/\s+/g, '');
const js = window.__eufemiaVersions[i] || window.__eufemiaVersions[0] || this.version;
return {
js,
css,
sha,
scopeElement
};
});
}
}
window.Eufemia = new Eufemia();
runCssVersionMismatchWarning();
runOldBuildDateWarning();
}
}
//# sourceMappingURL=Eufemia.js.map