feat(services): introduce DeesServiceLibLoader to lazy-load heavy client libraries from CDN and update components to use it
This commit is contained in:
@@ -7,9 +7,10 @@ import {
|
||||
css,
|
||||
cssManager,
|
||||
} from '@design.estate/dees-element';
|
||||
import { Terminal } from 'xterm';
|
||||
import { FitAddon } from 'xterm-addon-fit';
|
||||
import type { Terminal } from 'xterm';
|
||||
import type { FitAddon } from 'xterm-addon-fit';
|
||||
import { themeDefaultStyles } from '../../00theme.js';
|
||||
import { DeesServiceLibLoader } from '../../../services/index.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@@ -305,8 +306,15 @@ export class DeesWorkspaceTerminalPreview extends DeesElement {
|
||||
const domtoolsInstance = await this.domtoolsPromise;
|
||||
const isBright = domtoolsInstance.themeManager.goBrightBoolean;
|
||||
|
||||
// Create xterm terminal in read-only mode
|
||||
this.terminal = new Terminal({
|
||||
// Load xterm from CDN
|
||||
const libLoader = DeesServiceLibLoader.getInstance();
|
||||
const [xtermBundle, fitAddonBundle] = await Promise.all([
|
||||
libLoader.loadXterm(),
|
||||
libLoader.loadXtermFitAddon(),
|
||||
]);
|
||||
|
||||
// Create xterm terminal in read-only mode using CDN-loaded module
|
||||
this.terminal = new xtermBundle.Terminal({
|
||||
convertEol: true,
|
||||
cursorBlink: false,
|
||||
disableStdin: true,
|
||||
@@ -323,7 +331,7 @@ export class DeesWorkspaceTerminalPreview extends DeesElement {
|
||||
}
|
||||
});
|
||||
|
||||
this.fitAddon = new FitAddon();
|
||||
this.fitAddon = new fitAddonBundle.FitAddon();
|
||||
this.terminal.loadAddon(this.fitAddon);
|
||||
this.terminal.open(container);
|
||||
this.fitAddon.fit();
|
||||
|
||||
Reference in New Issue
Block a user