@industry-theme/xterm-terminal-panel 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -68,6 +68,7 @@ function getTerminalCSSVariables(theme) {
|
|
|
68
68
|
// src/components/ThemedTerminal.tsx
|
|
69
69
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
70
70
|
var SCROLL_DEBOUNCE_MS = 1000;
|
|
71
|
+
var DEBUG_RESIZE = true;
|
|
71
72
|
var ThemedTerminal = forwardRef(({
|
|
72
73
|
theme,
|
|
73
74
|
onData,
|
|
@@ -343,6 +344,16 @@ var ThemedTerminal = forwardRef(({
|
|
|
343
344
|
const scrollback2 = term.buffer.active.baseY;
|
|
344
345
|
const isAtTop = scrollY === 0;
|
|
345
346
|
const isAtBottom = scrollY + term.rows >= scrollback2 + term.rows;
|
|
347
|
+
if (DEBUG_RESIZE) {
|
|
348
|
+
console.log("[ThemedTerminal] onScroll event:", {
|
|
349
|
+
viewportY: scrollY,
|
|
350
|
+
baseY: scrollback2,
|
|
351
|
+
rows: term.rows,
|
|
352
|
+
isAtTop,
|
|
353
|
+
isAtBottom,
|
|
354
|
+
isScrollLocked: isScrollLockedRef.current
|
|
355
|
+
});
|
|
356
|
+
}
|
|
346
357
|
if (onScrollPositionChange) {
|
|
347
358
|
onScrollPositionChange({
|
|
348
359
|
isAtTop,
|
|
@@ -354,25 +365,79 @@ var ThemedTerminal = forwardRef(({
|
|
|
354
365
|
setTerminal(term);
|
|
355
366
|
const performFit = () => {
|
|
356
367
|
if (!fitAddonRef.current || !terminalRef.current || !term || !isVisibleRef.current) {
|
|
368
|
+
if (DEBUG_RESIZE) {
|
|
369
|
+
console.log("[ThemedTerminal] performFit skipped:", {
|
|
370
|
+
hasFitAddon: !!fitAddonRef.current,
|
|
371
|
+
hasTerminalRef: !!terminalRef.current,
|
|
372
|
+
hasTerm: !!term,
|
|
373
|
+
isVisible: isVisibleRef.current
|
|
374
|
+
});
|
|
375
|
+
}
|
|
357
376
|
return;
|
|
358
377
|
}
|
|
378
|
+
const containerRect = terminalRef.current.getBoundingClientRect();
|
|
379
|
+
const beforeCols = term.cols;
|
|
380
|
+
const beforeRows = term.rows;
|
|
381
|
+
const scrollYBefore = term.buffer.active.viewportY;
|
|
382
|
+
const baseYBefore = term.buffer.active.baseY;
|
|
383
|
+
if (DEBUG_RESIZE) {
|
|
384
|
+
console.log("[ThemedTerminal] performFit BEFORE:", {
|
|
385
|
+
container: { width: containerRect.width, height: containerRect.height },
|
|
386
|
+
terminal: { cols: beforeCols, rows: beforeRows },
|
|
387
|
+
scroll: { viewportY: scrollYBefore, baseY: baseYBefore },
|
|
388
|
+
isScrollLocked: isScrollLockedRef.current
|
|
389
|
+
});
|
|
390
|
+
}
|
|
359
391
|
fitAddonRef.current.fit();
|
|
392
|
+
const afterCols = term.cols;
|
|
393
|
+
const afterRows = term.rows;
|
|
394
|
+
const scrollYAfter = term.buffer.active.viewportY;
|
|
395
|
+
const baseYAfter = term.buffer.active.baseY;
|
|
396
|
+
if (DEBUG_RESIZE) {
|
|
397
|
+
console.log("[ThemedTerminal] performFit AFTER:", {
|
|
398
|
+
terminal: { cols: afterCols, rows: afterRows },
|
|
399
|
+
scroll: { viewportY: scrollYAfter, baseY: baseYAfter },
|
|
400
|
+
changed: beforeCols !== afterCols || beforeRows !== afterRows
|
|
401
|
+
});
|
|
402
|
+
}
|
|
360
403
|
if (isScrollLockedRef.current) {
|
|
361
404
|
requestAnimationFrame(() => {
|
|
405
|
+
if (DEBUG_RESIZE) {
|
|
406
|
+
console.log("[ThemedTerminal] scrollToBottom (scroll locked)");
|
|
407
|
+
}
|
|
362
408
|
term.scrollToBottom();
|
|
363
409
|
});
|
|
364
410
|
}
|
|
365
411
|
};
|
|
366
|
-
|
|
412
|
+
let resizeEventCount = 0;
|
|
413
|
+
const handleResize = (entry) => {
|
|
414
|
+
resizeEventCount++;
|
|
415
|
+
const eventNum = resizeEventCount;
|
|
416
|
+
if (DEBUG_RESIZE && entry) {
|
|
417
|
+
const rect = entry.contentRect;
|
|
418
|
+
console.log(`[ThemedTerminal] ResizeObserver #${eventNum}:`, {
|
|
419
|
+
width: rect.width,
|
|
420
|
+
height: rect.height,
|
|
421
|
+
timestamp: Date.now()
|
|
422
|
+
});
|
|
423
|
+
}
|
|
367
424
|
if (resizeTimeoutRef.current) {
|
|
425
|
+
if (DEBUG_RESIZE) {
|
|
426
|
+
console.log(`[ThemedTerminal] ResizeObserver #${eventNum}: debouncing (clearing previous timeout)`);
|
|
427
|
+
}
|
|
368
428
|
clearTimeout(resizeTimeoutRef.current);
|
|
369
429
|
}
|
|
370
430
|
resizeTimeoutRef.current = setTimeout(() => {
|
|
431
|
+
if (DEBUG_RESIZE) {
|
|
432
|
+
console.log(`[ThemedTerminal] ResizeObserver #${eventNum}: debounce complete, calling performFit`);
|
|
433
|
+
}
|
|
371
434
|
performFit();
|
|
372
435
|
}, 100);
|
|
373
436
|
};
|
|
374
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
375
|
-
|
|
437
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
438
|
+
for (const entry of entries) {
|
|
439
|
+
handleResize(entry);
|
|
440
|
+
}
|
|
376
441
|
});
|
|
377
442
|
if (terminalRef.current) {
|
|
378
443
|
resizeObserver.observe(terminalRef.current);
|
|
@@ -425,6 +490,12 @@ var ThemedTerminal = forwardRef(({
|
|
|
425
490
|
if (!terminal || !onResize)
|
|
426
491
|
return;
|
|
427
492
|
const disposable = terminal.onResize((size) => {
|
|
493
|
+
if (DEBUG_RESIZE) {
|
|
494
|
+
console.log("[ThemedTerminal] terminal.onResize event:", {
|
|
495
|
+
cols: size.cols,
|
|
496
|
+
rows: size.rows
|
|
497
|
+
});
|
|
498
|
+
}
|
|
428
499
|
onResize(size.cols, size.rows);
|
|
429
500
|
});
|
|
430
501
|
return () => {
|
|
@@ -454,9 +525,22 @@ var ThemedTerminal = forwardRef(({
|
|
|
454
525
|
}, [terminal, autoFocus, isVisible]);
|
|
455
526
|
useEffect(() => {
|
|
456
527
|
if (terminal && isVisible && fitAddonRef.current) {
|
|
528
|
+
if (DEBUG_RESIZE) {
|
|
529
|
+
console.log("[ThemedTerminal] Visibility change detected, scheduling fit:", {
|
|
530
|
+
isVisible,
|
|
531
|
+
cols: terminal.cols,
|
|
532
|
+
rows: terminal.rows
|
|
533
|
+
});
|
|
534
|
+
}
|
|
457
535
|
setTimeout(() => {
|
|
536
|
+
if (DEBUG_RESIZE) {
|
|
537
|
+
console.log("[ThemedTerminal] Visibility fit executing");
|
|
538
|
+
}
|
|
458
539
|
fitAddonRef.current?.fit();
|
|
459
540
|
if (isScrollLockedRef.current) {
|
|
541
|
+
if (DEBUG_RESIZE) {
|
|
542
|
+
console.log("[ThemedTerminal] Visibility fit: scrollToBottom (scroll locked)");
|
|
543
|
+
}
|
|
460
544
|
terminal.scrollToBottom();
|
|
461
545
|
}
|
|
462
546
|
}, 50);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemedTerminal.d.ts","sourceRoot":"","sources":["../../../src/components/ThemedTerminal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"ThemedTerminal.d.ts","sourceRoot":"","sources":["../../../src/components/ThemedTerminal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAkC3D,OAAO,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAEV,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,8BAA8B,CAAC;AAEtC,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,KAAK,EAAE,KAAK,CAAC;CACd;AAsBD,eAAO,MAAM,cAAc,4HAu6B1B,CAAC"}
|
package/package.json
CHANGED