diff --git a/BitFun@0.1.1 b/BitFun@0.1.1 deleted file mode 100644 index e69de29b..00000000 diff --git a/bitfun-mobile-web@0.1.1 b/bitfun-mobile-web@0.1.1 deleted file mode 100644 index e69de29b..00000000 diff --git a/node b/node deleted file mode 100644 index e69de29b..00000000 diff --git a/src/web-ui/src/tools/terminal/components/Terminal.tsx b/src/web-ui/src/tools/terminal/components/Terminal.tsx index d59e1b1f..aafbd1c1 100644 --- a/src/web-ui/src/tools/terminal/components/Terminal.tsx +++ b/src/web-ui/src/tools/terminal/components/Terminal.tsx @@ -17,6 +17,17 @@ import './Terminal.scss'; const log = createLogger('Terminal'); +type TerminalCoreWithMeasurement = XTerm & { + _core?: { + _charSizeService?: { + measure?: () => void; + }; + _renderService?: { + handleDevicePixelRatioChange?: () => void; + }; + }; +}; + /** * Clear xterm texture atlas when supported. * Used to force redraws and avoid WebGL cache artifacts. @@ -31,6 +42,12 @@ function clearTextureAtlas(terminal: XTerm): void { } } +function remeasureTerminal(terminal: XTerm): void { + const rawTerminal = terminal as TerminalCoreWithMeasurement; + rawTerminal._core?._charSizeService?.measure?.(); + rawTerminal._core?._renderService?.handleDevicePixelRatioChange?.(); +} + /** * Scroll to bottom when the cursor is below the viewport. */ @@ -460,6 +477,31 @@ const Terminal = forwardRef(({ } }); + let fontLoadCancelled = false; + if (typeof document !== 'undefined' && 'fonts' in document) { + const fontSet = document.fonts as FontFaceSet; + if (fontSet.status !== 'loaded') { + void fontSet.ready.then(() => { + if (fontLoadCancelled || !terminalRef.current) { + return; + } + + requestAnimationFrame(() => { + if (!terminalRef.current) return; + + remeasureTerminal(terminalRef.current); + fit(true); + + requestAnimationFrame(() => { + if (!terminalRef.current) return; + forceRefresh(terminalRef.current); + scrollToBottomIfNeeded(terminalRef.current); + }); + }); + }); + } + } + const dataDisposable = terminal.onData((data) => { onData?.(data); }); @@ -548,6 +590,7 @@ const Terminal = forwardRef(({ titleDisposable.dispose(); resizeObserver.disconnect(); intersectionObserver.disconnect(); + fontLoadCancelled = true; resizeDebouncer.dispose(); webglAddonRef.current?.dispose(); terminal.dispose(); diff --git a/src/web-ui/src/tools/terminal/utils/TerminalResizeDebouncer.ts b/src/web-ui/src/tools/terminal/utils/TerminalResizeDebouncer.ts index 34d1562f..fb6c9e30 100644 --- a/src/web-ui/src/tools/terminal/utils/TerminalResizeDebouncer.ts +++ b/src/web-ui/src/tools/terminal/utils/TerminalResizeDebouncer.ts @@ -115,7 +115,13 @@ export class TerminalResizeDebouncer { if (immediate || bufferLength < START_DEBOUNCING_THRESHOLD) { this.clearPendingJobs(); - this.executeResize(cols, rows, true); + if (this.isNewApi) { + const opts = this.options as ResizeDebounceOptions; + opts.onXtermResize(cols, rows); + this.scheduleBackendResize(cols, rows); + } else { + this.executeResize(cols, rows, true); + } return; } diff --git a/tsc b/tsc deleted file mode 100644 index e69de29b..00000000