feat(services): introduce DeesServiceLibLoader to lazy-load heavy client libraries from CDN and update components to use it

This commit is contained in:
2026-01-01 20:25:05 +00:00
parent 2a6457e192
commit d7f3594dd4
12 changed files with 410 additions and 39 deletions

View File

@@ -11,7 +11,8 @@ import { demoFunc } from './demo.js';
import { chartAreaStyles } from './styles.js';
import { renderChartArea } from './template.js';
import ApexCharts from 'apexcharts';
import type ApexCharts from 'apexcharts';
import { DeesServiceLibLoader } from '../../../services/index.js';
declare global {
interface HTMLElementTagNameMap {
@@ -150,7 +151,10 @@ export class DeesChartArea extends DeesElement {
public async firstUpdated() {
await this.domtoolsPromise;
// Load ApexCharts from CDN
const ApexChartsLib = await DeesServiceLibLoader.getInstance().loadApexCharts();
// Wait for next animation frame to ensure layout is complete
await new Promise(resolve => requestAnimationFrame(resolve));
@@ -353,7 +357,7 @@ export class DeesChartArea extends DeesElement {
};
try {
this.chart = new ApexCharts(this.shadowRoot.querySelector('.chartContainer'), options);
this.chart = new ApexChartsLib(this.shadowRoot.querySelector('.chartContainer'), options);
await this.chart.render();
// Give the chart a moment to fully initialize before resizing