react-terminal-viewer-cicd 2.1.1 → 3.0.0-beta.2

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.
Files changed (99) hide show
  1. package/README.md +11 -11
  2. package/dist/esm/Addon/EventEmiter.d.ts +1 -1
  3. package/dist/esm/Addon/HighlightAddon.d.ts +1 -1
  4. package/dist/esm/Addon/SearchAddon.d.ts +1 -1
  5. package/dist/esm/Addon/WorkerLog/LogWorker.js +1 -1
  6. package/dist/esm/Addon/WorkerLog/Logs.js +0 -2
  7. package/dist/esm/Addon/useAddon.d.ts +5 -5
  8. package/dist/esm/Addon/useAddon.js +1 -1
  9. package/dist/esm/Hooks/useDebounceInput.js +1 -1
  10. package/dist/esm/Hooks/useLocalStore.js +1 -1
  11. package/dist/esm/TerminalViewer/index.d.ts +4 -4
  12. package/dist/esm/TerminalViewer/index.js +4 -4
  13. package/dist/esm/TerminalViewerBody/index.d.ts +8 -8
  14. package/dist/esm/TerminalViewerBody/index.js +7 -7
  15. package/dist/esm/TerminalViewerVirtualDom/ReactVirtualized.d.ts +71 -0
  16. package/dist/esm/TerminalViewerVirtualDom/ReactVirtualized.js +309 -0
  17. package/dist/esm/TerminalViewerVirtualDom/ReactVirtuoso.d.ts +67 -0
  18. package/dist/esm/TerminalViewerVirtualDom/ReactVirtuoso.js +271 -0
  19. package/dist/esm/TerminalViewerVirtualDom/index.d.ts +1 -70
  20. package/dist/esm/TerminalViewerVirtualDom/index.js +2 -308
  21. package/dist/esm/TerminalViewerVirtualDom/virtualized.less +68 -0
  22. package/dist/esm/TerminalViewerVirtualDom/{index.less → virtuoso.less} +0 -1
  23. package/dist/esm/__mocks__/react-virtualized.js +14 -0
  24. package/dist/esm/__mocks__/styleMock.js +1 -0
  25. package/dist/esm/index.d.ts +4 -5
  26. package/dist/esm/index.js +4 -5
  27. package/dist/esm/mock/index.d.ts +3 -0
  28. package/dist/esm/mock/index.js +3 -0
  29. package/dist/esm/types.d.ts +4 -4
  30. package/dist/worker/.dumi/tmp/core/defineApp.d.ts +22 -0
  31. package/dist/worker/.dumi/tmp/core/exportStaticRuntimePlugin.d.ts +1 -0
  32. package/dist/worker/.dumi/tmp/core/helmet.d.ts +3 -0
  33. package/dist/worker/.dumi/tmp/core/helmetContext.d.ts +1 -0
  34. package/dist/worker/.dumi/tmp/core/history.d.ts +5 -0
  35. package/dist/worker/.dumi/tmp/core/historyIntelli.d.ts +50 -0
  36. package/dist/worker/.dumi/tmp/core/plugin.d.ts +8 -0
  37. package/dist/worker/.dumi/tmp/core/pluginConfig.d.ts +341 -0
  38. package/dist/worker/.dumi/tmp/core/route.d.ts +83 -0
  39. package/dist/worker/.dumi/tmp/core/terminal.d.ts +14 -0
  40. package/dist/worker/.dumi/tmp/dumi/exports.d.ts +3 -0
  41. package/dist/worker/.dumi/tmp/dumi/locales/config.d.ts +106 -0
  42. package/dist/worker/.dumi/tmp/dumi/locales/runtime.d.ts +2 -0
  43. package/dist/worker/.dumi/tmp/dumi/meta/atoms.d.ts +1 -0
  44. package/dist/worker/.dumi/tmp/dumi/meta/exports.d.ts +31 -0
  45. package/dist/worker/.dumi/tmp/dumi/meta/index.d.ts +39 -0
  46. package/dist/worker/.dumi/tmp/dumi/meta/runtime.d.ts +3 -0
  47. package/dist/worker/.dumi/tmp/dumi/meta/tabs.d.ts +1 -0
  48. package/dist/worker/.dumi/tmp/dumi/theme/ContextWrapper.d.ts +2 -0
  49. package/dist/worker/.dumi/tmp/exports.d.ts +10 -0
  50. package/dist/worker/.dumi/tmp/plugin-html2sketch/index.d.ts +1 -0
  51. package/dist/worker/.dumi/tmp/testBrowser.d.ts +8 -0
  52. package/dist/worker/.dumirc.d.ts +2 -0
  53. package/dist/worker/Addon/EventEmiter.d.ts +1 -1
  54. package/dist/worker/Addon/HighlightAddon.d.ts +1 -1
  55. package/dist/worker/Addon/SearchAddon.d.ts +1 -1
  56. package/dist/worker/Addon/useAddon.d.ts +4 -4
  57. package/dist/worker/TerminalViewer/index.d.ts +1 -1
  58. package/dist/worker/TerminalViewerBody/index.d.ts +5 -5
  59. package/dist/worker/index.d.ts +1 -1
  60. package/dist/worker/log.worker.js +1 -1
  61. package/dist/worker/log.worker.js.map +1 -1
  62. package/dist/worker/mock/index.d.ts +3 -0
  63. package/dist/worker/src/Addon/EventEmiter.d.ts +18 -0
  64. package/dist/worker/src/Addon/HighlightAddon.d.ts +26 -0
  65. package/dist/worker/src/Addon/LineNumberAddon.d.ts +39 -0
  66. package/dist/worker/src/Addon/SearchAddon.d.ts +140 -0
  67. package/dist/worker/src/Addon/WorkerLog/GlobalContext.d.ts +10 -0
  68. package/dist/worker/src/Addon/WorkerLog/LimitMap.d.ts +14 -0
  69. package/dist/worker/src/Addon/WorkerLog/LogWorker.d.ts +2 -0
  70. package/dist/worker/src/Addon/WorkerLog/Logs.d.ts +21 -0
  71. package/dist/worker/src/Addon/WorkerLog/Mark.d.ts +36 -0
  72. package/dist/worker/src/Addon/WorkerLog/Searcher.d.ts +16 -0
  73. package/dist/worker/src/Addon/WorkerLog/WebWokerServer.d.ts +10 -0
  74. package/dist/worker/src/Addon/WorkerLog/WebWorkerClient.d.ts +13 -0
  75. package/dist/worker/src/Addon/WorkerLog/log.worker.d.ts +1 -0
  76. package/dist/worker/src/Addon/WorkerLog/types.d.ts +18 -0
  77. package/dist/worker/src/Addon/useAddon.d.ts +9 -0
  78. package/dist/worker/src/Hooks/useBatchProcess.d.ts +2 -0
  79. package/dist/worker/src/Hooks/useCache.d.ts +31 -0
  80. package/dist/worker/src/Hooks/useDebounceInput.d.ts +3 -0
  81. package/dist/worker/src/Hooks/useLocalStore.d.ts +2 -0
  82. package/dist/worker/src/Hooks/useRemote.d.ts +30 -0
  83. package/dist/worker/src/Hooks/useRemote.test.d.ts +1 -0
  84. package/dist/worker/src/Hooks/useThrottle.d.ts +2 -0
  85. package/dist/worker/src/Hooks/useWorkerLogs.d.ts +9 -0
  86. package/dist/worker/src/TerminalViewer/index.d.ts +185 -0
  87. package/dist/worker/src/TerminalViewer/index.test.d.ts +1 -0
  88. package/dist/worker/src/TerminalViewerBody/index.d.ts +87 -0
  89. package/dist/worker/src/TerminalViewerBody/index.test.d.ts +1 -0
  90. package/dist/worker/src/TerminalViewerHeader/index.d.ts +88 -0
  91. package/dist/worker/src/TerminalViewerToolBar/index.d.ts +46 -0
  92. package/dist/worker/src/TerminalViewerVirtualDom/ReactVirtualized.d.ts +71 -0
  93. package/dist/worker/src/TerminalViewerVirtualDom/ReactVirtuoso.d.ts +67 -0
  94. package/dist/worker/src/TerminalViewerVirtualDom/index.d.ts +2 -0
  95. package/dist/worker/src/index.d.ts +8 -0
  96. package/dist/worker/src/mock/index.d.ts +15 -0
  97. package/dist/worker/src/types.d.ts +30 -0
  98. package/dist/worker/types.d.ts +4 -4
  99. package/package.json +27 -17
package/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  <h1 align="center">
2
- react-terminal-viewer
2
+ gitee-terminal-viewer
3
3
  </h1>
4
4
 
5
5
  <p align="center">基于 xterm.js 内核的 React 日志组件</p>
6
6
 
7
7
  <p align="center">
8
- <a href="https://gitee.com/oschina/react-terminal-viewer/gitee_go/pipelines"><img src="https://img.shields.io/badge/codecov-20%25-green" data-canonical-src="https://img.shields.io/badge/codecov-20%25-green"/></a>
9
- <a href="https://www.npmjs.com/package/react-terminal-viewer">
10
- <img src="https://img.shields.io/npm/v/react-terminal-viewer/latest"
11
- data-canonical-src="https://img.shields.io/npm/v/react-terminal-viewer/latest"/>
8
+ <a href="https://gitee.com/oschina/gitee-terminal-viewer/gitee_go/pipelines"><img src="https://img.shields.io/badge/codecov-20%25-green" data-canonical-src="https://img.shields.io/badge/codecov-20%25-green"/></a>
9
+ <a href="https://www.npmjs.com/package/gitee-terminal-viewer">
10
+ <img src="https://img.shields.io/npm/v/gitee-terminal-viewer/latest"
11
+ data-canonical-src="https://img.shields.io/npm/v/gitee-terminal-viewer/latest"/>
12
12
  </a>
13
- <img src="https://img.shields.io/npm/l/react-terminal-viewer" data-canonical-src="https://img.shields.io/npm/l/react-terminal-viewer"/>
13
+ <img src="https://img.shields.io/npm/l/gitee-terminal-viewer" data-canonical-src="https://img.shields.io/npm/l/gitee-terminal-viewer"/>
14
14
  </p>
15
15
 
16
- ![Preview png](https://gitee.com/oschina/react-terminal-viewer/raw/master/docs/preview.png)
16
+ ![Preview png](https://gitee.com/oschina/gitee-terminal-viewer/raw/master/docs/preview.png)
17
17
 
18
18
  ## 功能
19
19
 
@@ -41,20 +41,20 @@
41
41
  使用 npm 或 yarn 把这个 package 安装到你的项目依赖中:
42
42
 
43
43
  ```
44
- npm install react-terminal-viewer
44
+ npm install gitee-terminal-viewer
45
45
  ```
46
46
 
47
47
 
48
48
 
49
49
  ```
50
- yarn add react-terminal-viewer
50
+ yarn add gitee-terminal-viewer
51
51
  ```
52
52
 
53
53
  ## 使用
54
54
 
55
55
  ```tsx
56
56
  import React, { useRef } from 'react';
57
- import TerminalViewer from 'react-terminal-viewer';
57
+ import TerminalViewer from 'gitee-terminal-viewer';
58
58
  export default () => {
59
59
  const ref = useRef();
60
60
  const data = 'echo success';
@@ -104,7 +104,7 @@ webpack 配置:
104
104
  new CopyPlugin({
105
105
  patterns: [
106
106
  {
107
- from: path.resolve(__dirname, 'node_modules/react-terminal-viewer/dist/worker'),
107
+ from: path.resolve(__dirname, 'node_modules/gitee-terminal-viewer/dist/worker'),
108
108
  to: path.resolve(__dirname, 'dist/scripts/worker'),
109
109
  filter: (file) => file.includes('worker'),
110
110
  },
@@ -1,4 +1,4 @@
1
- import { IDisposable } from 'xterm';
1
+ import { IDisposable } from '@xterm/xterm';
2
2
  export interface IEvent<T, U = void> {
3
3
  (listener: (arg1: T, arg2: U) => any): IDisposable;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { Terminal, ITerminalAddon } from 'xterm';
1
+ import { ITerminalAddon, Terminal } from '@xterm/xterm';
2
2
  export interface IHighlightOptions {
3
3
  keyword: string;
4
4
  ignoreSensitive?: boolean;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 从 https://github.com/xtermjs/xterm.js/blob/master/addons/xterm-addon-search/src/SearchAddon.ts 复制以解决部分问题
3
3
  */
4
- import { Terminal, ITerminalAddon } from 'xterm';
4
+ import { ITerminalAddon, Terminal } from '@xterm/xterm';
5
5
  export interface ISearchOptions {
6
6
  regex?: boolean;
7
7
  wholeWord?: boolean;
@@ -1,7 +1,7 @@
1
1
  function LogWorker() {
2
2
  var workerPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/worker';
3
3
  var worker = null;
4
- var version = "2.1.1" || '0.0.0';
4
+ var version = "3.0.0-beta.2" || '0.0.0';
5
5
  var path = workerPath.includes('http') ? "".concat(workerPath, "/log.worker.js") : "".concat(window.location.origin).concat(workerPath, "/log.worker.js");
6
6
  var blob = new Blob(["importScripts(\"".concat(path, "?v=").concat(version, "\")")], {
7
7
  type: 'application/javascript'
@@ -5,8 +5,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- /* eslint-disable no-plusplus */
9
- // eslint-disable-next-line import/no-named-default
10
8
  import { default as AnsiUp } from 'ansi_up';
11
9
  import LimitMap from "./LimitMap";
12
10
  import Searcher from "./Searcher";
@@ -1,9 +1,9 @@
1
- import { Terminal } from 'xterm';
2
- import { FitAddon } from 'xterm-addon-fit';
3
- import { CanvasAddon } from 'xterm-addon-canvas';
4
- import { WebLinksAddon } from 'xterm-addon-web-links';
5
- import { SearchAddon } from './SearchAddon';
1
+ import { CanvasAddon } from '@xterm/addon-canvas';
2
+ import { FitAddon } from '@xterm/addon-fit';
3
+ import { WebLinksAddon } from '@xterm/addon-web-links';
4
+ import { Terminal } from '@xterm/xterm';
6
5
  import { HighlightAddon } from './HighlightAddon';
6
+ import { SearchAddon } from './SearchAddon';
7
7
  export type AddonType = FitAddon | WebLinksAddon | SearchAddon | HighlightAddon | CanvasAddon;
8
8
  declare const useAddon: (terminal: Terminal | undefined, Addon: new () => AddonType, loadable: boolean, callback?: ((term: Terminal, instance: AddonType) => void) | undefined) => AddonType | undefined;
9
9
  export default useAddon;
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { useEffect, useState, useRef } from 'react';
7
+ import { useEffect, useRef, useState } from 'react';
8
8
  var useAddon = function useAddon(terminal, Addon, loadable, callback) {
9
9
  var _useState = useState(),
10
10
  _useState2 = _slicedToArray(_useState, 2),
@@ -1,4 +1,4 @@
1
- import { useRef, useEffect, useCallback } from 'react';
1
+ import { useCallback, useEffect, useRef } from 'react';
2
2
 
3
3
  // eslint-disable-next-line @typescript-eslint/ban-types
4
4
  function useDebounceInput(cb) {
@@ -1,6 +1,6 @@
1
1
  import localforage from 'localforage';
2
2
  var localStore = localforage.createInstance({
3
- name: 'react-terminal-viewer',
3
+ name: 'gitee-terminal-viewer',
4
4
  version: 2
5
5
  });
6
6
  var useLocalStore = function useLocalStore() {
@@ -1,10 +1,10 @@
1
+ import { ITerminalOptions } from '@xterm/xterm';
1
2
  import React from 'react';
2
- import { ITerminalOptions } from 'xterm';
3
+ import type { IHighlightOptions } from '../Addon/HighlightAddon';
3
4
  import type { ISearchOptions } from '../Addon/SearchAddon';
4
- import type { IRemoteOptions } from '../Hooks/useRemote';
5
5
  import type { ICacheOptions } from '../Hooks/useCache';
6
- import type { IHighlightOptions } from '../Addon/HighlightAddon';
7
- import { ExtraOptions, TerminalRef, LogAfterProps } from '../types';
6
+ import type { IRemoteOptions } from '../Hooks/useRemote';
7
+ import { ExtraOptions, LogAfterProps, TerminalRef } from '../types';
8
8
  import './index.less';
9
9
  export interface TerminalViewerProps {
10
10
  /**
@@ -10,14 +10,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import React, { forwardRef, useCallback, useState, useImperativeHandle, useRef, useEffect, useMemo } from 'react';
13
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
14
14
  import { createPortal } from 'react-dom';
15
+ import globalContext from "../Addon/WorkerLog/GlobalContext";
15
16
  import useDebounceInput from "../Hooks/useDebounceInput";
16
- import TerminalViewerHeader from "../TerminalViewerHeader";
17
17
  import TerminalViewerBody from "../TerminalViewerBody";
18
- import TerminalViewerVirtualDom from "../TerminalViewerVirtualDom";
18
+ import TerminalViewerHeader from "../TerminalViewerHeader";
19
19
  import TerminalViewerToolBar from "../TerminalViewerToolBar";
20
- import globalContext from "../Addon/WorkerLog/GlobalContext";
20
+ import TerminalViewerVirtualDom from "../TerminalViewerVirtualDom";
21
21
  import "./index.less";
22
22
  var defaultSearchOptions = {
23
23
  regex: false,
@@ -1,15 +1,15 @@
1
+ import { CanvasAddon } from '@xterm/addon-canvas';
2
+ import { FitAddon } from '@xterm/addon-fit';
3
+ import { WebLinksAddon } from '@xterm/addon-web-links';
4
+ import { ITerminalOptions, Terminal } from '@xterm/xterm';
5
+ import '@xterm/xterm/css/xterm.css';
1
6
  import React from 'react';
2
- import { Terminal, ITerminalOptions } from 'xterm';
3
- import 'xterm/css/xterm.css';
4
- import { FitAddon } from 'xterm-addon-fit';
5
- import { WebLinksAddon } from 'xterm-addon-web-links';
6
- import { CanvasAddon } from 'xterm-addon-canvas';
7
- import { SearchAddon } from '../Addon/SearchAddon';
7
+ import type { IHighlightOptions } from '../Addon/HighlightAddon';
8
8
  import { HighlightAddon } from '../Addon/HighlightAddon';
9
+ import { SearchAddon } from '../Addon/SearchAddon';
9
10
  import type { AddonType } from '../Addon/useAddon';
10
- import type { IRemoteOptions } from '../Hooks/useRemote';
11
11
  import type { ICacheOptions } from '../Hooks/useCache';
12
- import type { IHighlightOptions } from '../Addon/HighlightAddon';
12
+ import type { IRemoteOptions } from '../Hooks/useRemote';
13
13
  import { TerminalRef } from '../types';
14
14
  import './index.less';
15
15
  export interface TerminalExposedRef {
@@ -13,14 +13,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
13
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
15
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
- import React, { forwardRef, useState, useEffect, useRef, useImperativeHandle } from 'react';
17
- import { Terminal } from 'xterm';
18
- import 'xterm/css/xterm.css';
19
- import { FitAddon } from 'xterm-addon-fit';
20
- import { WebLinksAddon } from 'xterm-addon-web-links';
21
- import { CanvasAddon } from 'xterm-addon-canvas';
22
- import { SearchAddon } from "../Addon/SearchAddon";
16
+ import { CanvasAddon } from '@xterm/addon-canvas';
17
+ import { FitAddon } from '@xterm/addon-fit';
18
+ import { WebLinksAddon } from '@xterm/addon-web-links';
19
+ import { Terminal } from '@xterm/xterm';
20
+ import '@xterm/xterm/css/xterm.css';
21
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
23
22
  import { HighlightAddon } from "../Addon/HighlightAddon";
23
+ import { SearchAddon } from "../Addon/SearchAddon";
24
24
  import useAddon from "../Addon/useAddon";
25
25
  import useRemote from "../Hooks/useRemote";
26
26
  import useThrottle from "../Hooks/useThrottle";
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import type { ListRowProps } from 'react-virtualized';
3
+ import { IHighlightOptions } from '../Addon/HighlightAddon';
4
+ import type { SearcherRef } from '../Addon/WorkerLog/types';
5
+ import type { ICacheOptions } from '../Hooks/useCache';
6
+ import type { IRemoteOptions } from '../Hooks/useRemote';
7
+ import { ExtraOptions, LogAfterProps, TerminalRef, VirtualDomTerminal } from '../types';
8
+ import './virtualized.less';
9
+ export interface TerminalViewerVirtualDomProps {
10
+ /**
11
+ * @description.zh-CN 是否自动拉伸填充容器宽高
12
+ * @default true
13
+ */
14
+ fit?: boolean;
15
+ /**
16
+ * @description.zh-CN 外层样式类名
17
+ */
18
+ className?: string;
19
+ /**
20
+ * @description.zh-CN 自定义空文本显示
21
+ */
22
+ empty?: React.ReactNode;
23
+ /**
24
+ *@description.zh-CN 是否开启自动滚动到底部
25
+ *@default true
26
+ */
27
+ autoScroll?: boolean;
28
+ /**
29
+ * @description.zh-CN 自动滚动到某一行,开启后自动滚动到底部失效
30
+ */
31
+ scrollToRow?: number;
32
+ /**
33
+ * @description.zh-CN 设置日志后置标签,仅在开启虚拟 DOM 生效
34
+ */
35
+ logAfter?: React.FunctionComponent<LogAfterProps> | React.ComponentClass<LogAfterProps>;
36
+ /**
37
+ * @description.zh-CN 用于渲染日志的默认数据,如 "echo 1\r\necho2"
38
+ * @default '''
39
+ */
40
+ defaultData?: string;
41
+ /**
42
+ * @description.zh-CN 远程搜索配置
43
+ *
44
+ */
45
+ remoteOptions?: IRemoteOptions;
46
+ /**
47
+ * @description.zh-CN 缓存配置,仅在配置远程加载后有效,如 `expires: 60 * 1000` 表示自动清理已过期一分钟的缓存
48
+ */
49
+ cacheOptions?: ICacheOptions;
50
+ /**
51
+ * @description.zh-CN 高亮选项
52
+ */
53
+ highlightOptions?: IHighlightOptions[];
54
+ /**
55
+ * @description.zh-CN 额外的功能选项 { showLineNumber 仅 虚拟 DOM 模式支持}
56
+ */
57
+ extraOptions?: ExtraOptions;
58
+ /**
59
+ * @description.zh-CN 插件加载成功后的回调
60
+ */
61
+ onAddonReady?: (instance?: VirtualDomTerminal, addon?: SearcherRef) => void;
62
+ /**
63
+ * @description.zh-CN 加载状态变更后的回调
64
+ */
65
+ onLoading?: (loading: boolean) => void;
66
+ }
67
+ export type RowRenderProps = ListRowProps & {
68
+ style: object;
69
+ };
70
+ declare const ReactVirtualized: React.ForwardRefExoticComponent<TerminalViewerVirtualDomProps & React.RefAttributes<TerminalRef | undefined>>;
71
+ export default ReactVirtualized;
@@ -0,0 +1,309 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ /* eslint-disable react/no-danger */
11
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
12
+ import React, { createElement, forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
13
+ import { AutoSizer, CellMeasurer, CellMeasurerCache } from 'react-virtualized';
14
+ import List from 'react-virtualized/dist/es/List';
15
+ import useRemote from "../Hooks/useRemote";
16
+ import useThrottle from "../Hooks/useThrottle";
17
+ import useWorkerLogs from "../Hooks/useWorkerLogs";
18
+ import "./virtualized.less";
19
+ // eslint-disable-next-line react/display-name, max-len
20
+ var ReactVirtualized = /*#__PURE__*/forwardRef(function (_ref, ref) {
21
+ var fitProp = _ref.fit,
22
+ className = _ref.className,
23
+ empty = _ref.empty,
24
+ _ref$autoScroll = _ref.autoScroll,
25
+ autoScroll = _ref$autoScroll === void 0 ? true : _ref$autoScroll,
26
+ scrollToRow = _ref.scrollToRow,
27
+ logAfter = _ref.logAfter,
28
+ _ref$defaultData = _ref.defaultData,
29
+ defaultData = _ref$defaultData === void 0 ? '' : _ref$defaultData,
30
+ remoteOptions = _ref.remoteOptions,
31
+ cacheOptions = _ref.cacheOptions,
32
+ highlightOptions = _ref.highlightOptions,
33
+ extraOptions = _ref.extraOptions,
34
+ onLoading = _ref.onLoading,
35
+ onAddonReady = _ref.onAddonReady;
36
+ var fit = fitProp !== null && fitProp !== void 0 ? fitProp : true;
37
+ var domRef = useRef(null);
38
+ var mountedRef = useRef(false);
39
+ var listRef = useRef(null);
40
+ var isScrollTopRef = useRef(false);
41
+ var isScrollToRowFinished = useRef(false);
42
+ var exposedRef = useRef({
43
+ refresh: function refresh() {
44
+ return undefined;
45
+ }
46
+ });
47
+ var highlightOptionsRef = useRef(highlightOptions);
48
+ var extraOptionsRef = useRef(extraOptions);
49
+ var cacheRef = useRef(new CellMeasurerCache({
50
+ fixedWidth: true,
51
+ minHeight: 20,
52
+ defaultHeight: 20
53
+ }));
54
+ useEffect(function () {
55
+ highlightOptionsRef.current = highlightOptions;
56
+ extraOptionsRef.current = extraOptions;
57
+ });
58
+ var throttleFit = useThrottle(function () {
59
+ if (mountedRef.current && listRef.current) {
60
+ var _listRef$current;
61
+ cacheRef.current.clearAll();
62
+ (_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.recomputeRowHeights();
63
+ }
64
+ }, 3000);
65
+ var _useRemote = useRemote(defaultData,
66
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
67
+ function () {}, _objectSpread(_objectSpread({}, remoteOptions), {}, {
68
+ enableBatch: false
69
+ }), cacheOptions),
70
+ refresh = _useRemote.refresh,
71
+ data = _useRemote.data,
72
+ loading = _useRemote.loading,
73
+ cacheStore = _useRemote.cacheStore;
74
+ var _useWorkerLogs = useWorkerLogs(data, function (result) {
75
+ if (result.count > 0) {
76
+ setTimeout(function () {
77
+ var _listRef$current2;
78
+ (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.scrollToRow(result.markedKey);
79
+ }, 0);
80
+ }
81
+ }),
82
+ logs = _useWorkerLogs.logs,
83
+ searcherRef = _useWorkerLogs.searcherRef,
84
+ working = _useWorkerLogs.working,
85
+ searcherResult = _useWorkerLogs.searcherResult;
86
+ var lineNumberWidth = useMemo(function () {
87
+ var _extraOptionsRef$curr, _domRef$current;
88
+ if (!((_extraOptionsRef$curr = extraOptionsRef.current) !== null && _extraOptionsRef$curr !== void 0 && _extraOptionsRef$curr.showLineNumber)) {
89
+ return 48;
90
+ }
91
+ var existSpan = (_domRef$current = domRef.current) === null || _domRef$current === void 0 ? void 0 : _domRef$current.querySelector('.terminal-viewer-text-placeholder');
92
+ var span = existSpan || document.createElement('span');
93
+ span.className = 'terminal-viewer-text-placeholder';
94
+ span.innerHTML = logs.length.toString();
95
+ if (!existSpan) {
96
+ var _domRef$current2;
97
+ (_domRef$current2 = domRef.current) === null || _domRef$current2 === void 0 || _domRef$current2.appendChild(span);
98
+ }
99
+ return span.clientWidth || 48;
100
+ }, [logs.length]);
101
+ var rowRender = useCallback(function (_ref2) {
102
+ var _matchOption$decorati, _matchOption$decorati2, _extraOptionsRef$curr2;
103
+ var key = _ref2.key,
104
+ index = _ref2.index,
105
+ style = _ref2.style,
106
+ parent = _ref2.parent;
107
+ var rowClassName = index === scrollToRow ? 'terminal-viewer-virtual-list-row terminal-viewer-virtual-list-row--active' : 'terminal-viewer-virtual-list-row';
108
+ var log = searcherResult.map[index] || logs[index];
109
+ var options = highlightOptionsRef.current || [];
110
+ var matchOption = options.find(function (option) {
111
+ var _logs$index2;
112
+ var keyword = option.keyword || '';
113
+ if (option.ignoreSensitive) {
114
+ var _logs$index$toLowerCa, _logs$index;
115
+ var lowerString = (_logs$index$toLowerCa = (_logs$index = logs[index]) === null || _logs$index === void 0 ? void 0 : _logs$index.toLowerCase()) !== null && _logs$index$toLowerCa !== void 0 ? _logs$index$toLowerCa : '';
116
+ return lowerString.includes(keyword.toLowerCase()) || lowerString.includes(keyword);
117
+ }
118
+ return (_logs$index2 = logs[index]) === null || _logs$index2 === void 0 ? void 0 : _logs$index2.includes(keyword);
119
+ });
120
+ var hlStyle = {
121
+ color: (matchOption === null || matchOption === void 0 || (_matchOption$decorati = matchOption.decorations) === null || _matchOption$decorati === void 0 ? void 0 : _matchOption$decorati.matchForegroundColor) || 'inherit',
122
+ background: (matchOption === null || matchOption === void 0 || (_matchOption$decorati2 = matchOption.decorations) === null || _matchOption$decorati2 === void 0 ? void 0 : _matchOption$decorati2.matchBackground) || 'inherit'
123
+ };
124
+ if (typeof log === 'undefined') {
125
+ return /*#__PURE__*/React.createElement("div", {
126
+ style: _objectSpread(_objectSpread({}, style !== null && style !== void 0 ? style : {}), {}, {
127
+ height: '4px'
128
+ }),
129
+ className: rowClassName
130
+ });
131
+ }
132
+ return (
133
+ /*#__PURE__*/
134
+ // @ts-ignore tsx-ignore
135
+ React.createElement(CellMeasurer, {
136
+ cache: cacheRef.current,
137
+ style: style,
138
+ columnIndex: 0,
139
+ key: key,
140
+ rowIndex: index,
141
+ parent: parent
142
+ }, /*#__PURE__*/React.createElement("div", {
143
+ style: style,
144
+ className: rowClassName
145
+ }, !!((_extraOptionsRef$curr2 = extraOptionsRef.current) !== null && _extraOptionsRef$curr2 !== void 0 && _extraOptionsRef$curr2.showLineNumber) && /*#__PURE__*/React.createElement("span", {
146
+ className: "terminal-viewer-line-number",
147
+ style: {
148
+ minWidth: "".concat(lineNumberWidth, "px")
149
+ }
150
+ }, index + 1), /*#__PURE__*/React.createElement("span", {
151
+ className: "terminal-viewer-pre",
152
+ style: hlStyle,
153
+ dangerouslySetInnerHTML: {
154
+ __html: log || ''
155
+ }
156
+ }), logAfter && /*#__PURE__*/createElement(logAfter, {
157
+ index: index,
158
+ content: log
159
+ })))
160
+ );
161
+ }, [logAfter, scrollToRow, lineNumberWidth, logs, searcherResult]);
162
+ useEffect(function () {
163
+ var dom;
164
+ var resizeObserver;
165
+ if (fit) {
166
+ resizeObserver = new ResizeObserver(throttleFit);
167
+ dom = domRef.current;
168
+ if (dom) {
169
+ resizeObserver.observe(dom);
170
+ }
171
+ }
172
+ return function () {
173
+ if (dom && resizeObserver) {
174
+ resizeObserver.unobserve(dom);
175
+ resizeObserver.disconnect();
176
+ }
177
+ };
178
+ }, [fit, throttleFit]);
179
+ useEffect(function () {
180
+ var _listRef$current3;
181
+ cacheRef.current.clear(0, 0);
182
+ (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 || _listRef$current3.recomputeRowHeights();
183
+ }, [lineNumberWidth, logs]);
184
+ useEffect(function () {
185
+ if (mountedRef.current && logs.length > 0) {
186
+ if (typeof scrollToRow !== 'undefined' && Number.isInteger(scrollToRow) && !isScrollToRowFinished.current) {
187
+ if (logs.length >= scrollToRow) {
188
+ setTimeout(function () {
189
+ var _listRef$current4;
190
+ isScrollToRowFinished.current = true;
191
+ (_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 || _listRef$current4.scrollToRow(scrollToRow);
192
+ }, 0);
193
+ } else {
194
+ setTimeout(function () {
195
+ var _listRef$current5;
196
+ (_listRef$current5 = listRef.current) === null || _listRef$current5 === void 0 || _listRef$current5.scrollToRow(logs.length);
197
+ }, 0);
198
+ }
199
+ }
200
+ if (autoScroll && !isScrollTopRef.current && searcherResult.count <= 0 && typeof scrollToRow === 'undefined') {
201
+ setTimeout(function () {
202
+ var _listRef$current6;
203
+ (_listRef$current6 = listRef.current) === null || _listRef$current6 === void 0 || _listRef$current6.scrollToRow(logs.length);
204
+ }, 0);
205
+ }
206
+ }
207
+ });
208
+ useEffect(function () {
209
+ if (typeof onLoading === 'function') {
210
+ onLoading(working || loading);
211
+ }
212
+ }, [working, loading, onLoading]);
213
+ useEffect(function () {
214
+ mountedRef.current = true;
215
+ return function () {
216
+ mountedRef.current = false;
217
+ isScrollTopRef.current = false;
218
+ };
219
+ }, []);
220
+ useEffect(function () {
221
+ exposedRef.current.refresh = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
222
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
223
+ while (1) switch (_context.prev = _context.next) {
224
+ case 0:
225
+ _context.next = 2;
226
+ return refresh();
227
+ case 2:
228
+ case "end":
229
+ return _context.stop();
230
+ }
231
+ }, _callee);
232
+ }));
233
+ });
234
+ useImperativeHandle(ref, function () {
235
+ return {
236
+ el: domRef.current,
237
+ refresh: function () {
238
+ var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
239
+ var _exposedRef$current;
240
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
241
+ while (1) switch (_context2.prev = _context2.next) {
242
+ case 0:
243
+ return _context2.abrupt("return", ((_exposedRef$current = exposedRef.current) === null || _exposedRef$current === void 0 ? void 0 : _exposedRef$current.refresh) && exposedRef.current.refresh());
244
+ case 1:
245
+ case "end":
246
+ return _context2.stop();
247
+ }
248
+ }, _callee2);
249
+ }));
250
+ function refresh() {
251
+ return _refresh.apply(this, arguments);
252
+ }
253
+ return refresh;
254
+ }(),
255
+ cacheStore: cacheStore,
256
+ addons: {
257
+ search: function search() {
258
+ return searcherRef.current;
259
+ }
260
+ },
261
+ terminal: function terminal() {
262
+ return {
263
+ scrollToTop: function scrollToTop() {
264
+ var _listRef$current7;
265
+ (_listRef$current7 = listRef.current) === null || _listRef$current7 === void 0 || _listRef$current7.scrollToRow(0);
266
+ isScrollTopRef.current = true;
267
+ },
268
+ scrollToBottom: function scrollToBottom() {
269
+ var _listRef$current8;
270
+ (_listRef$current8 = listRef.current) === null || _listRef$current8 === void 0 || _listRef$current8.scrollToRow(logs.length);
271
+ isScrollTopRef.current = false;
272
+ }
273
+ };
274
+ }
275
+ };
276
+ });
277
+ useEffect(function () {
278
+ if (typeof onAddonReady === 'function') {
279
+ onAddonReady(undefined, searcherRef.current);
280
+ }
281
+ }, [searcherRef, onAddonReady]);
282
+ return /*#__PURE__*/React.createElement("div", {
283
+ className: ['terminal-viewer-body', className].filter(Boolean).join(' '),
284
+ ref: domRef
285
+ }, logs.length !== 0 &&
286
+ /*#__PURE__*/
287
+ // @ts-ignore jsx-element
288
+ React.createElement(AutoSizer, null, function (_ref4) {
289
+ var width = _ref4.width,
290
+ height = _ref4.height;
291
+ return (
292
+ /*#__PURE__*/
293
+ // @ts-ignore jsx-element
294
+ React.createElement(List, {
295
+ ref: listRef,
296
+ height: height,
297
+ width: width,
298
+ className: "terminal-viewer-virtual-list",
299
+ rowHeight: cacheRef.current.rowHeight,
300
+ rowRenderer: rowRender,
301
+ rowCount: logs.length + 1,
302
+ scrollToAlignment: "center"
303
+ })
304
+ );
305
+ }), (logs === null || logs === void 0 ? void 0 : logs.length) === 0 && (empty || /*#__PURE__*/React.createElement("div", {
306
+ className: "terminal-viewer-body-empty"
307
+ }, "\u6682\u65E0\u6570\u636E")));
308
+ });
309
+ export default ReactVirtualized;