mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-01-18 15:13:00 +00:00
BREAKING: In a minority of cases syntax updates may break apps running in very old browsers (such as Internet Explorer), or apps that build Docsify in a custom way with old build tools. To upgrade, build Docsify for older browsers in a custom way, or update existing build tools to handle newer syntax. DEPRECATED: `$docsify.themeColor` is deprecated and will be eventually removed, use a `--theme-color` CSS variable in your style sheet.
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
import { Router } from './router/index.js';
|
|
import { Render } from './render/index.js';
|
|
import { Fetch } from './fetch/index.js';
|
|
import { Events } from './event/index.js';
|
|
import { VirtualRoutes } from './virtual-routes/index.js';
|
|
import initGlobalAPI from './global-api.js';
|
|
|
|
import config from './config.js';
|
|
import { isFn } from './util/core.js';
|
|
import { Lifecycle } from './init/lifecycle.js';
|
|
|
|
/** @typedef {new (...args: any[]) => any} Constructor */
|
|
|
|
// eslint-disable-next-line new-cap
|
|
export class Docsify extends Fetch(
|
|
// eslint-disable-next-line new-cap
|
|
Events(Render(VirtualRoutes(Router(Lifecycle(Object)))))
|
|
) {
|
|
constructor() {
|
|
super();
|
|
|
|
this.config = config(this);
|
|
|
|
this.initLifecycle(); // Init hooks
|
|
this.initPlugin(); // Install plugins
|
|
this.callHook('init');
|
|
this.initRouter(); // Add router
|
|
this.initRender(); // Render base DOM
|
|
this.initEvent(); // Bind events
|
|
this.initFetch(); // Fetch data
|
|
this.callHook('mounted');
|
|
}
|
|
|
|
initPlugin() {
|
|
this.config.plugins.forEach(fn => {
|
|
try {
|
|
isFn(fn) && fn(this._lifecycle, this);
|
|
} catch (err) {
|
|
if (this.config.catchPluginErrors) {
|
|
const errTitle = 'Docsify plugin error';
|
|
console.error(errTitle, err);
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Global API
|
|
*/
|
|
initGlobalAPI();
|