This commit is contained in:
2026-04-04 11:05:01 +00:00
parent 4dba14060e
commit ff32470d8a
29 changed files with 1431 additions and 2 deletions

View File

@@ -74,6 +74,28 @@ export interface ILightweightChartsBundle {
};
}
/**
* Minimal type for an ECharts instance (loaded from CDN)
*/
export interface IEchartsInstance {
setOption(option: Record<string, any>, notMerge?: boolean): void;
resize(opts?: { width?: number; height?: number }): void;
dispose(): void;
on(eventName: string, handler: (...args: any[]) => void): void;
off(eventName: string, handler?: (...args: any[]) => void): void;
getOption(): Record<string, any>;
clear(): void;
}
/**
* Bundle type for Apache ECharts
*/
export interface IEchartsBundle {
init: (dom: HTMLElement, theme?: string | object | null, opts?: Record<string, any>) => IEchartsInstance;
dispose: (chart: IEchartsInstance | HTMLElement | string) => void;
getInstanceByDom: (dom: HTMLElement) => IEchartsInstance | undefined;
}
/**
* Bundle type for Tiptap editor and extensions
*/
@@ -108,6 +130,7 @@ export class DeesServiceLibLoader {
private xtermSearchAddonLib: IXtermSearchAddonBundle | null = null;
private highlightJsLib: HLJSApi | null = null;
private lightweightChartsLib: ILightweightChartsBundle | null = null;
private echartsLib: IEchartsBundle | null = null;
private tiptapLib: ITiptapBundle | null = null;
// Loading promises to prevent duplicate concurrent loads
@@ -116,6 +139,7 @@ export class DeesServiceLibLoader {
private xtermSearchAddonLoadingPromise: Promise<IXtermSearchAddonBundle> | null = null;
private highlightJsLoadingPromise: Promise<HLJSApi> | null = null;
private lightweightChartsLoadingPromise: Promise<ILightweightChartsBundle> | null = null;
private echartsLoadingPromise: Promise<IEchartsBundle> | null = null;
private tiptapLoadingPromise: Promise<ITiptapBundle> | null = null;
private constructor() {}
@@ -296,6 +320,34 @@ body > div[style*="top: -50000px"][style*="width: 50000px"] {
return this.lightweightChartsLoadingPromise;
}
/**
* Load Apache ECharts from CDN
* @returns Promise resolving to ECharts bundle
*/
public async loadEcharts(): Promise<IEchartsBundle> {
if (this.echartsLib) {
return this.echartsLib;
}
if (this.echartsLoadingPromise) {
return this.echartsLoadingPromise;
}
this.echartsLoadingPromise = (async () => {
const url = `${CDN_BASE}/echarts@${CDN_VERSIONS.echarts}/+esm`;
const module = await import(/* @vite-ignore */ url);
this.echartsLib = {
init: module.init,
dispose: module.dispose,
getInstanceByDom: module.getInstanceByDom,
};
return this.echartsLib;
})();
return this.echartsLoadingPromise;
}
/**
* Load Tiptap rich text editor and extensions from CDN
* @returns Promise resolving to Tiptap bundle with Editor and extensions
@@ -348,6 +400,7 @@ body > div[style*="top: -50000px"][style*="width: 50000px"] {
this.loadXtermSearchAddon(),
this.loadHighlightJs(),
this.loadLightweightCharts(),
this.loadEcharts(),
this.loadTiptap(),
]);
}
@@ -355,7 +408,7 @@ body > div[style*="top: -50000px"][style*="width: 50000px"] {
/**
* Check if a specific library is already loaded
*/
public isLoaded(library: 'xterm' | 'xtermFitAddon' | 'xtermSearchAddon' | 'highlightJs' | 'lightweightCharts' | 'tiptap'): boolean {
public isLoaded(library: 'xterm' | 'xtermFitAddon' | 'xtermSearchAddon' | 'highlightJs' | 'lightweightCharts' | 'echarts' | 'tiptap'): boolean {
switch (library) {
case 'xterm':
return this.xtermLib !== null;
@@ -367,6 +420,8 @@ body > div[style*="top: -50000px"][style*="width: 50000px"] {
return this.highlightJsLib !== null;
case 'lightweightCharts':
return this.lightweightChartsLib !== null;
case 'echarts':
return this.echartsLib !== null;
case 'tiptap':
return this.tiptapLib !== null;
default: