@industry-theme/xterm-terminal-panel 0.4.3 → 0.4.5
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,
|
|
@@ -338,11 +339,48 @@ var ThemedTerminal = forwardRef(({
|
|
|
338
339
|
} catch (e) {
|
|
339
340
|
console.warn("[ThemedTerminal] WebGL not available, using canvas renderer:", e);
|
|
340
341
|
}
|
|
342
|
+
let lastBaseY = 0;
|
|
343
|
+
let isRewriteInProgress = false;
|
|
344
|
+
let rewriteStabilizeTimeout = null;
|
|
341
345
|
const scrollDisposable = term.onScroll(() => {
|
|
342
346
|
const scrollY = term.buffer.active.viewportY;
|
|
343
347
|
const scrollback2 = term.buffer.active.baseY;
|
|
344
348
|
const isAtTop = scrollY === 0;
|
|
345
349
|
const isAtBottom = scrollY + term.rows >= scrollback2 + term.rows;
|
|
350
|
+
if (DEBUG_RESIZE) {
|
|
351
|
+
console.log("[ThemedTerminal] onScroll event:", {
|
|
352
|
+
viewportY: scrollY,
|
|
353
|
+
baseY: scrollback2,
|
|
354
|
+
rows: term.rows,
|
|
355
|
+
isAtTop,
|
|
356
|
+
isAtBottom,
|
|
357
|
+
isScrollLocked: isScrollLockedRef.current,
|
|
358
|
+
isRewriteInProgress
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (lastBaseY > 50 && scrollback2 < lastBaseY * 0.1) {
|
|
362
|
+
if (DEBUG_RESIZE) {
|
|
363
|
+
console.log("[ThemedTerminal] Content rewrite STARTED:", {
|
|
364
|
+
previousBaseY: lastBaseY,
|
|
365
|
+
currentBaseY: scrollback2
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
isRewriteInProgress = true;
|
|
369
|
+
}
|
|
370
|
+
if (isRewriteInProgress) {
|
|
371
|
+
if (rewriteStabilizeTimeout) {
|
|
372
|
+
clearTimeout(rewriteStabilizeTimeout);
|
|
373
|
+
}
|
|
374
|
+
term.scrollToBottom();
|
|
375
|
+
rewriteStabilizeTimeout = setTimeout(() => {
|
|
376
|
+
if (DEBUG_RESIZE) {
|
|
377
|
+
console.log("[ThemedTerminal] Content rewrite COMPLETE, stabilized at baseY:", scrollback2);
|
|
378
|
+
}
|
|
379
|
+
isRewriteInProgress = false;
|
|
380
|
+
term.scrollToBottom();
|
|
381
|
+
}, 150);
|
|
382
|
+
}
|
|
383
|
+
lastBaseY = scrollback2;
|
|
346
384
|
if (onScrollPositionChange) {
|
|
347
385
|
onScrollPositionChange({
|
|
348
386
|
isAtTop,
|
|
@@ -354,25 +392,79 @@ var ThemedTerminal = forwardRef(({
|
|
|
354
392
|
setTerminal(term);
|
|
355
393
|
const performFit = () => {
|
|
356
394
|
if (!fitAddonRef.current || !terminalRef.current || !term || !isVisibleRef.current) {
|
|
395
|
+
if (DEBUG_RESIZE) {
|
|
396
|
+
console.log("[ThemedTerminal] performFit skipped:", {
|
|
397
|
+
hasFitAddon: !!fitAddonRef.current,
|
|
398
|
+
hasTerminalRef: !!terminalRef.current,
|
|
399
|
+
hasTerm: !!term,
|
|
400
|
+
isVisible: isVisibleRef.current
|
|
401
|
+
});
|
|
402
|
+
}
|
|
357
403
|
return;
|
|
358
404
|
}
|
|
405
|
+
const containerRect = terminalRef.current.getBoundingClientRect();
|
|
406
|
+
const beforeCols = term.cols;
|
|
407
|
+
const beforeRows = term.rows;
|
|
408
|
+
const scrollYBefore = term.buffer.active.viewportY;
|
|
409
|
+
const baseYBefore = term.buffer.active.baseY;
|
|
410
|
+
if (DEBUG_RESIZE) {
|
|
411
|
+
console.log("[ThemedTerminal] performFit BEFORE:", {
|
|
412
|
+
container: { width: containerRect.width, height: containerRect.height },
|
|
413
|
+
terminal: { cols: beforeCols, rows: beforeRows },
|
|
414
|
+
scroll: { viewportY: scrollYBefore, baseY: baseYBefore },
|
|
415
|
+
isScrollLocked: isScrollLockedRef.current
|
|
416
|
+
});
|
|
417
|
+
}
|
|
359
418
|
fitAddonRef.current.fit();
|
|
419
|
+
const afterCols = term.cols;
|
|
420
|
+
const afterRows = term.rows;
|
|
421
|
+
const scrollYAfter = term.buffer.active.viewportY;
|
|
422
|
+
const baseYAfter = term.buffer.active.baseY;
|
|
423
|
+
if (DEBUG_RESIZE) {
|
|
424
|
+
console.log("[ThemedTerminal] performFit AFTER:", {
|
|
425
|
+
terminal: { cols: afterCols, rows: afterRows },
|
|
426
|
+
scroll: { viewportY: scrollYAfter, baseY: baseYAfter },
|
|
427
|
+
changed: beforeCols !== afterCols || beforeRows !== afterRows
|
|
428
|
+
});
|
|
429
|
+
}
|
|
360
430
|
if (isScrollLockedRef.current) {
|
|
361
431
|
requestAnimationFrame(() => {
|
|
432
|
+
if (DEBUG_RESIZE) {
|
|
433
|
+
console.log("[ThemedTerminal] scrollToBottom (scroll locked)");
|
|
434
|
+
}
|
|
362
435
|
term.scrollToBottom();
|
|
363
436
|
});
|
|
364
437
|
}
|
|
365
438
|
};
|
|
366
|
-
|
|
439
|
+
let resizeEventCount = 0;
|
|
440
|
+
const handleResize = (entry) => {
|
|
441
|
+
resizeEventCount++;
|
|
442
|
+
const eventNum = resizeEventCount;
|
|
443
|
+
if (DEBUG_RESIZE && entry) {
|
|
444
|
+
const rect = entry.contentRect;
|
|
445
|
+
console.log(`[ThemedTerminal] ResizeObserver #${eventNum}:`, {
|
|
446
|
+
width: rect.width,
|
|
447
|
+
height: rect.height,
|
|
448
|
+
timestamp: Date.now()
|
|
449
|
+
});
|
|
450
|
+
}
|
|
367
451
|
if (resizeTimeoutRef.current) {
|
|
452
|
+
if (DEBUG_RESIZE) {
|
|
453
|
+
console.log(`[ThemedTerminal] ResizeObserver #${eventNum}: debouncing (clearing previous timeout)`);
|
|
454
|
+
}
|
|
368
455
|
clearTimeout(resizeTimeoutRef.current);
|
|
369
456
|
}
|
|
370
457
|
resizeTimeoutRef.current = setTimeout(() => {
|
|
458
|
+
if (DEBUG_RESIZE) {
|
|
459
|
+
console.log(`[ThemedTerminal] ResizeObserver #${eventNum}: debounce complete, calling performFit`);
|
|
460
|
+
}
|
|
371
461
|
performFit();
|
|
372
462
|
}, 100);
|
|
373
463
|
};
|
|
374
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
375
|
-
|
|
464
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
465
|
+
for (const entry of entries) {
|
|
466
|
+
handleResize(entry);
|
|
467
|
+
}
|
|
376
468
|
});
|
|
377
469
|
if (terminalRef.current) {
|
|
378
470
|
resizeObserver.observe(terminalRef.current);
|
|
@@ -387,6 +479,9 @@ var ThemedTerminal = forwardRef(({
|
|
|
387
479
|
if (scrollDebounceRef.current) {
|
|
388
480
|
clearTimeout(scrollDebounceRef.current);
|
|
389
481
|
}
|
|
482
|
+
if (rewriteStabilizeTimeout) {
|
|
483
|
+
clearTimeout(rewriteStabilizeTimeout);
|
|
484
|
+
}
|
|
390
485
|
if (webglAddonRef.current) {
|
|
391
486
|
webglAddonRef.current.dispose();
|
|
392
487
|
webglAddonRef.current = null;
|
|
@@ -425,6 +520,12 @@ var ThemedTerminal = forwardRef(({
|
|
|
425
520
|
if (!terminal || !onResize)
|
|
426
521
|
return;
|
|
427
522
|
const disposable = terminal.onResize((size) => {
|
|
523
|
+
if (DEBUG_RESIZE) {
|
|
524
|
+
console.log("[ThemedTerminal] terminal.onResize event:", {
|
|
525
|
+
cols: size.cols,
|
|
526
|
+
rows: size.rows
|
|
527
|
+
});
|
|
528
|
+
}
|
|
428
529
|
onResize(size.cols, size.rows);
|
|
429
530
|
});
|
|
430
531
|
return () => {
|
|
@@ -454,9 +555,22 @@ var ThemedTerminal = forwardRef(({
|
|
|
454
555
|
}, [terminal, autoFocus, isVisible]);
|
|
455
556
|
useEffect(() => {
|
|
456
557
|
if (terminal && isVisible && fitAddonRef.current) {
|
|
558
|
+
if (DEBUG_RESIZE) {
|
|
559
|
+
console.log("[ThemedTerminal] Visibility change detected, scheduling fit:", {
|
|
560
|
+
isVisible,
|
|
561
|
+
cols: terminal.cols,
|
|
562
|
+
rows: terminal.rows
|
|
563
|
+
});
|
|
564
|
+
}
|
|
457
565
|
setTimeout(() => {
|
|
566
|
+
if (DEBUG_RESIZE) {
|
|
567
|
+
console.log("[ThemedTerminal] Visibility fit executing");
|
|
568
|
+
}
|
|
458
569
|
fitAddonRef.current?.fit();
|
|
459
570
|
if (isScrollLockedRef.current) {
|
|
571
|
+
if (DEBUG_RESIZE) {
|
|
572
|
+
console.log("[ThemedTerminal] Visibility fit: scrollToBottom (scroll locked)");
|
|
573
|
+
}
|
|
460
574
|
terminal.scrollToBottom();
|
|
461
575
|
}
|
|
462
576
|
}, 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,4HAq9B1B,CAAC"}
|
package/package.json
CHANGED