update
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export { DeesServiceLibLoader } from './DeesServiceLibLoader.js';
|
||||
export type { IXtermBundle, IXtermFitAddonBundle, IXtermSearchAddonBundle, IXtermSearchAddon, ITiptapBundle, ILightweightChartsBundle } from './DeesServiceLibLoader.js';
|
||||
export type { IXtermBundle, IXtermFitAddonBundle, IXtermSearchAddonBundle, IXtermSearchAddon, ITiptapBundle, ILightweightChartsBundle, IEchartsBundle, IEchartsInstance } from './DeesServiceLibLoader.js';
|
||||
export { CDN_BASE, CDN_VERSIONS } from './versions.js';
|
||||
|
||||
@@ -7,6 +7,7 @@ export const CDN_VERSIONS = {
|
||||
xtermAddonFit: '0.8.0',
|
||||
xtermAddonSearch: '0.13.0',
|
||||
highlightJs: '11.11.1',
|
||||
echarts: '5.6.0',
|
||||
lightweightCharts: '5.1.0',
|
||||
tiptap: '2.27.2',
|
||||
fontawesome: '7.2.0',
|
||||
|
||||
Reference in New Issue
Block a user