You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/packages/ui-default/entry.js

60 lines
1.6 KiB
JavaScript

import $ from 'jquery';
import * as bus from './bus';
window.Hydro = {
extraPages: [],
preload: [],
components: {},
utils: {},
node_modules: {},
version: process.env.VERSION,
bus,
};
window.externalModules = {};
console.log(
'%c%s%c%s',
'color:red;font-size:24px;',
' Welcome to\n',
'color:blue;font-weight:bold;',
`\
__ __ __
/ / / /_ ______/ /________
/ /_/ / / / / __ / ___/ __ \\
/ __ / /_/ / /_/ / / / /_/ /
/_/ /_/\\__, /\\__,_/_/ \\____/
/____/
`,
);
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then((registration) => {
console.log('SW registered: ', registration);
}).catch((registrationError) => {
console.log('SW registration failed: ', registrationError);
});
});
}
document.addEventListener('DOMContentLoaded', async () => {
window.UiContext = JSON.parse(window.UiContext);
const PageLoader = '<div class="page-loader nojs--hide" style="display:none;"><div class="loader"></div></div>';
$('body').prepend(PageLoader);
$('.page-loader').fadeIn(500);
// eslint-disable-next-line camelcase
try { __webpack_public_path__ = UiContext.cdn_prefix; } catch (e) { }
const [data, HydroExports] = await Promise.all([
fetch(`/constant/${UiContext.constantVersion}`, { cache: 'force-cache' }).then((r) => r.json()),
import('./api'),
]);
Object.assign(window, { HydroExports });
eval(data[0]); // eslint-disable-line no-eval
data.shift();
window.Hydro.preload = data;
import('./hydro');
}, false);