-
Notifications
You must be signed in to change notification settings - Fork 60
/
index.js
65 lines (62 loc) · 2.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { config } from '@nuxeo/nuxeo-elements';
import { importHTML, importHref } from '@nuxeo/nuxeo-ui-elements/import-href.js';
import { setFallbackNotificationTarget } from '@nuxeo/nuxeo-elements/nuxeo-notify-behavior.js';
// To fix WEBUI-833 and to disable the Roboto font request
const disableRobotoFont = () => {
window.polymerSkipLoadingFontRoboto = true;
};
const loadApp = () => import(/* webpackMode: "eager" */ './elements/nuxeo-app.js');
const loadLegacy = () => import(/* webpackMode: "eager" */ './legacy.js');
const loadBundle = () =>
import('./elements/nuxeo-web-ui-bundle.html').then(({ default: bundleHtml }) => importHTML(bundleHtml));
const loadAddons = async () => {
const bundles = [...Nuxeo.UI.bundles, 'nuxeo-spreadsheet'];
// load addons / bundles
// NXP-26977: await loading of addons
await Promise.all(
bundles.map((url) => {
if (url.endsWith('.html')) {
return new Promise((resolve, reject) => importHref(url, resolve, reject));
}
return import(
/* webpackChunkName: "[request]" */
/* webpackInclude: /addons\/[^\/]+\/index.js$/ */
// eslint-disable-next-line comma-dangle
`./addons/${url}`
).catch(() => import(/* webpackIgnore: true */ `./${url}.bundle.js`));
}),
);
};
const setupApp = async () =>
customElements.whenDefined('nuxeo-app').then(() => {
if (Nuxeo && Nuxeo.UI) {
Nuxeo.UI.app = document.querySelector('nuxeo-app');
if (!Nuxeo.UI.app) {
console.error('could not find nuxeo-app');
}
setFallbackNotificationTarget(Nuxeo.UI.app);
} else {
console.error('could not find nuxeo-app');
}
});
const loadRouting = async () => {
if (config.get('router.htmlImport')) {
importHref(Nuxeo.UI.app.resolveUrl('routing.html'));
} else {
return import(/* webpackMode: "eager" */ './elements/routing.js');
}
};
const ready =
!navigator.webdriver || window.automationReady
? Promise.resolve()
: new Promise((resolve) => {
document.addEventListener('automation-ready', resolve);
});
ready
.then(disableRobotoFont)
.then(loadApp)
.then(loadLegacy)
.then(loadBundle)
.then(loadAddons)
.then(setupApp)
.then(loadRouting);