@industry-theme/xterm-terminal-panel 0.5.32 → 0.5.34

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
@@ -35,7 +35,7 @@ import {
35
35
  // package.json
36
36
  var package_default = {
37
37
  name: "@industry-theme/xterm-terminal-panel",
38
- version: "0.5.32",
38
+ version: "0.5.34",
39
39
  description: "Industry-themed xterm.js terminal components with panel framework integration",
40
40
  type: "module",
41
41
  main: "dist/index.js",
@@ -1756,39 +1756,22 @@ var TerminalPanel = ({
1756
1756
  const [sessionId, setSessionId] = useState3(null);
1757
1757
  const [error, setError] = useState3(null);
1758
1758
  const [isInitializing, setIsInitializing] = useState3(true);
1759
- const [usingMessagePort, setUsingMessagePort] = useState3(false);
1760
1759
  const [scrollPosition, setScrollPosition] = useState3({
1761
1760
  isAtTop: false,
1762
1761
  isAtBottom: true,
1763
1762
  isScrollLocked: false
1764
1763
  });
1765
1764
  const terminalRef = useRef2(null);
1766
- const dataPortRef = useRef2(null);
1767
1765
  const isScrollLockedRef = useRef2(scrollPosition.isScrollLocked);
1768
1766
  const terminalDirectory = getTerminalDirectory(context2, terminalScope);
1769
1767
  const pendingSessionIdRef = useRef2(null);
1770
1768
  useEffect3(() => {
1771
1769
  let mounted = true;
1772
- let unsubscribePortReady = null;
1773
1770
  const initTerminal = async () => {
1774
1771
  try {
1775
1772
  if (!actions.createTerminalSession) {
1776
1773
  throw new Error("Terminal actions not available. Host must provide createTerminalSession action.");
1777
1774
  }
1778
- if (!actions.onTerminalPortReady) {
1779
- throw new Error("MessagePort support not available. Host must provide onTerminalPortReady action.");
1780
- }
1781
- unsubscribePortReady = actions.onTerminalPortReady((data, port) => {
1782
- if (data.sessionId === pendingSessionIdRef.current || data.sessionId === sessionId) {
1783
- dataPortRef.current = port;
1784
- if (typeof port.start === "function") {
1785
- port.start();
1786
- }
1787
- if (mounted) {
1788
- setUsingMessagePort(true);
1789
- }
1790
- }
1791
- });
1792
1775
  const id = await actions.createTerminalSession({
1793
1776
  cwd: terminalDirectory || undefined
1794
1777
  });
@@ -1796,13 +1779,6 @@ var TerminalPanel = ({
1796
1779
  if (actions.claimTerminalOwnership) {
1797
1780
  await actions.claimTerminalOwnership(id);
1798
1781
  }
1799
- if (!dataPortRef.current && actions.requestTerminalDataPort) {
1800
- try {
1801
- await actions.requestTerminalDataPort(id);
1802
- } catch (portErr) {
1803
- console.warn("[TerminalPanel] requestTerminalDataPort failed:", portErr);
1804
- }
1805
- }
1806
1782
  if (mounted) {
1807
1783
  setSessionId(id);
1808
1784
  setIsInitializing(false);
@@ -1817,73 +1793,48 @@ var TerminalPanel = ({
1817
1793
  initTerminal();
1818
1794
  return () => {
1819
1795
  mounted = false;
1820
- if (unsubscribePortReady) {
1821
- unsubscribePortReady();
1822
- }
1823
1796
  if (pendingSessionIdRef.current && actions.destroyTerminalSession) {
1824
1797
  actions.destroyTerminalSession(pendingSessionIdRef.current);
1825
1798
  }
1826
- if (dataPortRef.current) {
1827
- if (typeof dataPortRef.current.close === "function") {
1828
- dataPortRef.current.close();
1829
- }
1830
- dataPortRef.current = null;
1831
- }
1832
1799
  };
1833
1800
  }, []);
1834
1801
  useEffect3(() => {
1835
- if (usingMessagePort)
1836
- return;
1837
1802
  if (!sessionId)
1838
1803
  return;
1839
- const timeout = setTimeout(() => {
1840
- if (!dataPortRef.current) {
1841
- console.error("[TerminalPanel] MessagePort not received after timeout - terminal data will not be displayed");
1842
- setError("MessagePort not available. Terminal data streaming requires MessagePort support from the host.");
1843
- }
1844
- }, 5000);
1845
- return () => clearTimeout(timeout);
1846
- }, [sessionId, usingMessagePort]);
1847
- useEffect3(() => {
1848
- if (!usingMessagePort || !dataPortRef.current) {
1804
+ if (!actions.onTerminalData) {
1805
+ setError("Host does not provide onTerminalData. Terminal data cannot be displayed.");
1849
1806
  return;
1850
1807
  }
1851
- const port = dataPortRef.current;
1852
- let lastWriteTime = 0;
1853
1808
  let cursorMovedToHome = false;
1809
+ let lastWriteTime = 0;
1854
1810
  let autoScrollTimeout = null;
1855
- const handleMessage = (event) => {
1856
- if (event.data?.type === "DATA" && terminalRef.current) {
1857
- const data = event.data.data;
1858
- if (data.includes("\x1B[H")) {
1859
- cursorMovedToHome = true;
1860
- lastWriteTime = Date.now();
1861
- }
1862
- terminalRef.current.write(data);
1863
- if (cursorMovedToHome && isScrollLockedRef.current) {
1864
- if (autoScrollTimeout) {
1865
- clearTimeout(autoScrollTimeout);
1866
- }
1867
- autoScrollTimeout = setTimeout(() => {
1868
- const now = Date.now();
1869
- const timeSinceLastWrite = now - lastWriteTime;
1870
- if (timeSinceLastWrite >= 100 && cursorMovedToHome && terminalRef.current) {
1871
- terminalRef.current.write("\x1B[9999;1H");
1872
- cursorMovedToHome = false;
1873
- }
1874
- }, 100);
1875
- }
1811
+ const unsubscribe = actions.onTerminalData(sessionId, (data) => {
1812
+ if (!terminalRef.current)
1813
+ return;
1814
+ if (data.includes("\x1B[H")) {
1815
+ cursorMovedToHome = true;
1876
1816
  lastWriteTime = Date.now();
1877
1817
  }
1878
- };
1879
- port.onmessage = handleMessage;
1818
+ terminalRef.current.write(data);
1819
+ if (cursorMovedToHome && isScrollLockedRef.current) {
1820
+ if (autoScrollTimeout)
1821
+ clearTimeout(autoScrollTimeout);
1822
+ autoScrollTimeout = setTimeout(() => {
1823
+ const timeSinceLastWrite = Date.now() - lastWriteTime;
1824
+ if (timeSinceLastWrite >= 100 && cursorMovedToHome && terminalRef.current) {
1825
+ terminalRef.current.write("\x1B[9999;1H");
1826
+ cursorMovedToHome = false;
1827
+ }
1828
+ }, 100);
1829
+ }
1830
+ lastWriteTime = Date.now();
1831
+ });
1880
1832
  return () => {
1881
- port.onmessage = null;
1882
- if (autoScrollTimeout) {
1833
+ if (autoScrollTimeout)
1883
1834
  clearTimeout(autoScrollTimeout);
1884
- }
1835
+ unsubscribe();
1885
1836
  };
1886
- }, [usingMessagePort]);
1837
+ }, [sessionId, actions.onTerminalData]);
1887
1838
  const handleTerminalData = useCallback4((data) => {
1888
1839
  if (sessionId && actions.writeToTerminal) {
1889
1840
  actions.writeToTerminal(sessionId, data);
@@ -1 +1 @@
1
- {"version":3,"file":"TerminalPanel.d.ts","sourceRoot":"","sources":["../../../src/panels/TerminalPanel.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,gBAAgB,CAAC;AAqBxE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAobtD,CAAC"}
1
+ {"version":3,"file":"TerminalPanel.d.ts","sourceRoot":"","sources":["../../../src/panels/TerminalPanel.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AA+BzD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA+VtD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@industry-theme/xterm-terminal-panel",
3
- "version": "0.5.32",
3
+ "version": "0.5.34",
4
4
  "description": "Industry-themed xterm.js terminal components with panel framework integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",