MCPcopy
hub / github.com/markmap/markmap / initialize

Function initialize

packages/markmap-autoloader/src/index.ts:28–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26};
27
28async function initialize() {
29 if (typeof autoLoaderOptions.provider === 'function') {
30 urlBuilder.setProvider(
31 (urlBuilder.provider = 'autoLoader'),
32 autoLoaderOptions.provider,
33 );
34 } else if (typeof autoLoaderOptions.provider === 'string') {
35 urlBuilder.provider = autoLoaderOptions.provider;
36 } else {
37 try {
38 await urlBuilder.findFastestProvider();
39 } catch {
40 // ignore
41 }
42 }
43 await Promise.all([
44 loadJS(
45 autoLoaderOptions.baseJs.map((item) =>
46 typeof item === 'string'
47 ? buildJSItem(urlBuilder.getFullUrl(item))
48 : item,
49 ),
50 ),
51 loadCSS(
52 autoLoaderOptions.baseCss.map((item) =>
53 typeof item === 'string'
54 ? buildCSSItem(urlBuilder.getFullUrl(item))
55 : item,
56 ),
57 ),
58 ]);
59 const { markmap } = window;
60 const style = document.createElement('style');
61 style.textContent = markmap.globalCSS;
62 // Insert global CSS to body so it has higher priority than prism.css, etc.
63 document.body.prepend(style);
64 autoLoaderOptions.onReady?.();
65}
66
67export const ready = initialize();
68

Callers 1

index.tsFile · 0.85

Calls 4

loadJSFunction · 0.90
buildJSItemFunction · 0.90
loadCSSFunction · 0.90
buildCSSItemFunction · 0.90

Tested by

no test coverage detected