react-terminal-viewer-cicd 3.0.0-beta.13 → 3.0.0-beta.15

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 (70) hide show
  1. package/README.md +4 -2
  2. package/dist/esm/Addon/WorkerLog/LogWorker.js +1 -1
  3. package/dist/esm/Hooks/useThrottle.js +1 -1
  4. package/dist/esm/Hooks/useWorkerLogs.d.ts +1 -1
  5. package/dist/esm/Hooks/useWorkerLogs.js +1 -1
  6. package/dist/esm/TerminalViewer/index.d.ts +11 -3
  7. package/dist/esm/TerminalViewer/index.js +19 -4
  8. package/dist/esm/TerminalViewerBody/index.d.ts +1 -1
  9. package/dist/esm/TerminalViewerHeader/index.d.ts +17 -3
  10. package/dist/esm/TerminalViewerHeader/index.js +9 -4
  11. package/dist/esm/TerminalViewerHeader/index.less +6 -4
  12. package/dist/esm/TerminalViewerToolBar/index.js +1 -1
  13. package/dist/esm/TerminalViewerVirtualDom/index.d.ts +6 -1
  14. package/dist/esm/TerminalViewerVirtualDom/index.js +14 -3
  15. package/dist/esm/TerminalViewerVirtualDom/useStreamStepWorkerLogs.d.ts +3 -0
  16. package/dist/esm/TerminalViewerVirtualDom/useStreamStepWorkerLogs.js +43 -6
  17. package/dist/esm/types.d.ts +6 -2
  18. package/dist/worker/src/Hooks/useWorkerLogs.d.ts +1 -1
  19. package/dist/worker/src/TerminalViewer/index.d.ts +11 -3
  20. package/dist/worker/src/TerminalViewerBody/index.d.ts +1 -1
  21. package/dist/worker/src/TerminalViewerHeader/CollapseButton.d.ts +21 -0
  22. package/dist/worker/src/TerminalViewerHeader/index.d.ts +17 -3
  23. package/dist/worker/src/TerminalViewerVirtualDom/index.d.ts +6 -1
  24. package/dist/worker/src/TerminalViewerVirtualDom/useStreamStepWorkerLogs.d.ts +3 -0
  25. package/dist/worker/src/types.d.ts +6 -2
  26. package/package.json +108 -108
  27. package/dist/worker/.dumi/tmp/core/exportStaticRuntimePlugin.d.ts +0 -1
  28. package/dist/worker/.dumi/tmp/core/helmet.d.ts +0 -3
  29. package/dist/worker/.dumi/tmp/core/helmetContext.d.ts +0 -1
  30. package/dist/worker/.dumi/tmp/dumi/locales/runtime.d.ts +0 -2
  31. package/dist/worker/.dumi/tmp/dumi/meta/runtime.d.ts +0 -3
  32. package/dist/worker/Addon/EventEmiter.d.ts +0 -18
  33. package/dist/worker/Addon/HighlightAddon.d.ts +0 -26
  34. package/dist/worker/Addon/SearchAddon.d.ts +0 -140
  35. package/dist/worker/Addon/WorkerLog/GlobalContext.d.ts +0 -10
  36. package/dist/worker/Addon/WorkerLog/LimitMap.d.ts +0 -14
  37. package/dist/worker/Addon/WorkerLog/LogWorker.d.ts +0 -2
  38. package/dist/worker/Addon/WorkerLog/Logs.d.ts +0 -21
  39. package/dist/worker/Addon/WorkerLog/Mark.d.ts +0 -36
  40. package/dist/worker/Addon/WorkerLog/Searcher.d.ts +0 -16
  41. package/dist/worker/Addon/WorkerLog/WebWokerServer.d.ts +0 -10
  42. package/dist/worker/Addon/WorkerLog/WebWorkerClient.d.ts +0 -13
  43. package/dist/worker/Addon/WorkerLog/log.worker.d.ts +0 -1
  44. package/dist/worker/Addon/WorkerLog/types.d.ts +0 -18
  45. package/dist/worker/Addon/useAddon.d.ts +0 -9
  46. package/dist/worker/Hooks/useBatchProcess.d.ts +0 -2
  47. package/dist/worker/Hooks/useCache.d.ts +0 -31
  48. package/dist/worker/Hooks/useDebounceInput.d.ts +0 -3
  49. package/dist/worker/Hooks/useLocalStore.d.ts +0 -2
  50. package/dist/worker/Hooks/useRemote.d.ts +0 -30
  51. package/dist/worker/Hooks/useRemote.test.d.ts +0 -1
  52. package/dist/worker/Hooks/useThrottle.d.ts +0 -2
  53. package/dist/worker/Hooks/useWorkerLogs.d.ts +0 -9
  54. package/dist/worker/TerminalViewer/index.d.ts +0 -185
  55. package/dist/worker/TerminalViewer/index.test.d.ts +0 -1
  56. package/dist/worker/TerminalViewerBody/index.d.ts +0 -87
  57. package/dist/worker/TerminalViewerBody/index.test.d.ts +0 -1
  58. package/dist/worker/TerminalViewerHeader/index.d.ts +0 -88
  59. package/dist/worker/TerminalViewerToolBar/index.d.ts +0 -46
  60. package/dist/worker/TerminalViewerVirtualDom/index.d.ts +0 -71
  61. package/dist/worker/index.d.ts +0 -9
  62. package/dist/worker/log.worker.dev.js +0 -3291
  63. package/dist/worker/log.worker.dev.js.map +0 -1
  64. package/dist/worker/mock/index.d.ts +0 -15
  65. package/dist/worker/src/Addon/LineNumberAddon.d.ts +0 -39
  66. package/dist/worker/src/TerminalViewerVirtualDom/ReactVirtualized.d.ts +0 -71
  67. package/dist/worker/src/TerminalViewerVirtualDom/ReactVirtuoso.d.ts +0 -67
  68. package/dist/worker/src/TerminalViewerVirtualDom/StatusIcon.d.ts +0 -4
  69. package/dist/worker/src/TerminalViewerVirtualDom/parsePipelineLogs.d.ts +0 -21
  70. package/dist/worker/types.d.ts +0 -30
package/README.md CHANGED
@@ -119,14 +119,16 @@ webpack 配置:
119
119
  ```
120
120
 
121
121
  ## 发布
122
+
122
123
  打标签后使用流水线发布或使用常规方式手动发布:
123
124
 
124
125
  ```bash
125
126
  npm version patch && npm publish
126
127
  ```
128
+
127
129
  ## 更新在线地址
128
130
 
129
- 合并代码后与打标签后使用流水线发布,使用常规方式合并代码与构建后,手动推送至deploy
131
+ 合并代码后与打标签后使用流水线发布,使用常规方式合并代码与构建后,手动推送至 deploy
130
132
 
131
133
  ## 修复已知问题
132
134
 
@@ -144,7 +146,7 @@ npm version patch && npm publish
144
146
  ## API
145
147
 
146
148
  | 属性名 | 描述 | 类型 | 默认值 |
147
- | --- | --- | --- | --- |
149
+ | --- | --- | --- | --- | --- | --- |
148
150
  | fit | 是否自动拉伸填充容器宽高 | boolean | true |
149
151
  | autoScroll | 是否开启自动滚动到底部 | boolean | true |
150
152
  | scrollToRow | 自动滚动到某一行,开启后自动滚动到底部失效 | number | -- |
@@ -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 = "3.0.0-beta.13" || '0.0.0';
4
+ var version = "3.0.0-beta.15" || '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'
@@ -1,5 +1,5 @@
1
- import { useRef, useCallback, useEffect } from 'react';
2
1
  import throttle from 'lodash.throttle';
2
+ import { useCallback, useEffect, useRef } from 'react';
3
3
  var useThrottle = function useThrottle(cb) {
4
4
  var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
5
5
  var cbRef = useRef(cb);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { SearchResultCallback, SearcherRef, SearcherResult } from '../Addon/WorkerLog/types';
2
+ import type { SearcherRef, SearcherResult, SearchResultCallback } from '../Addon/WorkerLog/types';
3
3
  export declare const useWorkerLogs: (string: string, changeCallback?: SearchResultCallback) => {
4
4
  logs: string[];
5
5
  working: boolean;
@@ -7,9 +7,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  /* eslint-disable @typescript-eslint/no-explicit-any */
8
8
  import { useEffect, useRef, useState } from 'react';
9
9
  import { v4 as uuidv4 } from 'uuid';
10
- import WebWorkerClient from "../Addon/WorkerLog/WebWorkerClient";
11
10
  import globalContext from "../Addon/WorkerLog/GlobalContext";
12
11
  import LogWorker from "../Addon/WorkerLog/LogWorker";
12
+ import WebWorkerClient from "../Addon/WorkerLog/WebWorkerClient";
13
13
  export var useWorkerLogs = function useWorkerLogs(string, changeCallback) {
14
14
  var prefixRef = useRef('prefix');
15
15
  var _useState = useState([]),
@@ -1,10 +1,10 @@
1
- import { ITerminalOptions } from '@xterm/xterm';
1
+ import { ITerminalOptions, Terminal } from '@xterm/xterm';
2
2
  import React from 'react';
3
3
  import type { IHighlightOptions } from '../Addon/HighlightAddon';
4
4
  import type { ISearchOptions } from '../Addon/SearchAddon';
5
5
  import type { ICacheOptions } from '../Hooks/useCache';
6
6
  import type { IRemoteOptions } from '../Hooks/useRemote';
7
- import { ExtraOptions, LogAfterProps, TerminalRef } from '../types';
7
+ import { ExtraOptions, LogAfterProps, TerminalRef, VirtualDomTerminal } from '../types';
8
8
  import './index.less';
9
9
  export interface TerminalViewerProps {
10
10
  /**
@@ -180,6 +180,14 @@ export interface TerminalViewerProps {
180
180
  * @description.zh-CN 刷新后的回调函数
181
181
  */
182
182
  onRefresh?: () => void;
183
+ /**
184
+ * @description.zh-CN 折叠状态变更后的回调
185
+ */
186
+ onCollapseStatusChange?: (allCollapsed: boolean) => void;
187
+ /**
188
+ * @description.zh-CN 折叠操作
189
+ */
190
+ collapseAction?: (terminal: Terminal | VirtualDomTerminal, allCollapsed: boolean) => React.ReactNode;
183
191
  }
184
- declare const TerminalViewer: React.ForwardRefExoticComponent<Omit<TerminalViewerProps, "ref"> & React.RefAttributes<TerminalRef | undefined>>;
192
+ declare const TerminalViewer: React.ForwardRefExoticComponent<Omit<TerminalViewerProps, "ref"> & React.RefAttributes<TerminalRef<Terminal | VirtualDomTerminal> | undefined>>;
185
193
  export default TerminalViewer;
@@ -70,7 +70,9 @@ var TerminalViewer = /*#__PURE__*/forwardRef(function (_ref, ref) {
70
70
  getContainer = _ref.getContainer,
71
71
  onTitleChange = _ref.onTitleChange,
72
72
  onLoading = _ref.onLoading,
73
- onRefresh = _ref.onRefresh;
73
+ onRefresh = _ref.onRefresh,
74
+ onCollapseStatusChange = _ref.onCollapseStatusChange,
75
+ collapseAction = _ref.collapseAction;
74
76
  var localSearchOptions = searchOptions !== null && searchOptions !== void 0 ? searchOptions : {};
75
77
  var instanceRef = useRef();
76
78
  var searchValueRef = useRef('');
@@ -93,6 +95,14 @@ var TerminalViewer = /*#__PURE__*/forwardRef(function (_ref, ref) {
93
95
  _useState8 = _slicedToArray(_useState7, 2),
94
96
  searchResult = _useState8[0],
95
97
  setSearchResult = _useState8[1];
98
+ var _useState9 = useState(false),
99
+ _useState10 = _slicedToArray(_useState9, 2),
100
+ allCollapsed = _useState10[0],
101
+ setAllCollapsed = _useState10[1];
102
+ var handleCollapseStatusChange = useCallback(function (collapsed) {
103
+ setAllCollapsed(collapsed);
104
+ onCollapseStatusChange === null || onCollapseStatusChange === void 0 || onCollapseStatusChange(collapsed);
105
+ }, [onCollapseStatusChange]);
96
106
  var searchOptionsRef = useRef(_objectSpread(_objectSpread({}, defaultSearchOptions), localSearchOptions));
97
107
  useEffect(function () {
98
108
  searchOptionsRef.current = _objectSpread(_objectSpread({}, defaultSearchOptions), localSearchOptions);
@@ -235,7 +245,10 @@ var TerminalViewer = /*#__PURE__*/forwardRef(function (_ref, ref) {
235
245
  onSearchPrev: handleSearchPrev,
236
246
  onSearchNext: handleSearchNext,
237
247
  onTitleChange: handleTitleChange,
238
- onRefresh: handleRefresh
248
+ onRefresh: handleRefresh,
249
+ terminalRef: instanceRef,
250
+ allCollapsed: allCollapsed,
251
+ collapseAction: collapseAction
239
252
  }), Array.isArray(tabs) && tabs.map(function (tab, index) {
240
253
  if (activeTabIndex === index) {
241
254
  return /*#__PURE__*/React.createElement(ViewerBody, {
@@ -255,7 +268,8 @@ var TerminalViewer = /*#__PURE__*/forwardRef(function (_ref, ref) {
255
268
  terminalOptions: terminalOptions,
256
269
  extraOptions: extraOptions,
257
270
  onAddonReady: handleAddonReady,
258
- onLoading: handleLoading
271
+ onLoading: handleLoading,
272
+ onCollapseStatusChange: handleCollapseStatusChange
259
273
  });
260
274
  }
261
275
  return null;
@@ -275,7 +289,8 @@ var TerminalViewer = /*#__PURE__*/forwardRef(function (_ref, ref) {
275
289
  terminalOptions: terminalOptions,
276
290
  extraOptions: extraOptions,
277
291
  onAddonReady: handleAddonReady,
278
- onLoading: handleLoading
292
+ onLoading: handleLoading,
293
+ onCollapseStatusChange: handleCollapseStatusChange
279
294
  }), toolbar || /*#__PURE__*/React.createElement(TerminalViewerToolBar, {
280
295
  icons: icons,
281
296
  fullScreen: fullScreen,
@@ -83,5 +83,5 @@ export interface TerminalViewerBodyProps {
83
83
  */
84
84
  onLoading?: (loading: boolean) => void;
85
85
  }
86
- declare const TerminalViewerBody: React.ForwardRefExoticComponent<TerminalViewerBodyProps & React.RefAttributes<TerminalRef | undefined>>;
86
+ declare const TerminalViewerBody: React.ForwardRefExoticComponent<TerminalViewerBodyProps & React.RefAttributes<TerminalRef<Terminal | import("../types").VirtualDomTerminal> | undefined>>;
87
87
  export default TerminalViewerBody;
@@ -1,6 +1,8 @@
1
+ import { Terminal } from '@xterm/xterm';
1
2
  import React from 'react';
3
+ import { TerminalRef, VirtualDomTerminal } from '../types';
2
4
  import './index.less';
3
- export interface TerminalViewerHeaderProps {
5
+ export interface TerminalViewerHeaderProps<T extends Terminal | VirtualDomTerminal = Terminal | VirtualDomTerminal> {
4
6
  /**
5
7
  * @description.zh-CN 搜索框 placeholder
6
8
  * @default 请输入
@@ -15,7 +17,7 @@ export interface TerminalViewerHeaderProps {
15
17
  * @description.zh-CN 是否支持清除搜索框
16
18
  * @default true
17
19
  */
18
- clearable?: string;
20
+ clearable?: boolean;
19
21
  /**
20
22
  * @description.zh-CN 是否支持刷新
21
23
  */
@@ -83,6 +85,18 @@ export interface TerminalViewerHeaderProps {
83
85
  *@description.zh-CN 点击刷新按钮后的回调
84
86
  */
85
87
  onRefresh?: (e: React.SyntheticEvent<HTMLSpanElement>) => void;
88
+ /**
89
+ * @description.zh-CN 终端实例
90
+ */
91
+ terminalRef?: React.MutableRefObject<TerminalRef<T> | undefined>;
92
+ /**
93
+ * @description.zh-CN 是否全部折叠
94
+ */
95
+ allCollapsed?: boolean;
96
+ /**
97
+ * @description.zh-CN 折叠操作
98
+ */
99
+ collapseAction?: (terminal: T, allCollapsed: boolean) => React.ReactNode;
86
100
  }
87
- declare const TerminalViewerHeader: React.FC<TerminalViewerHeaderProps>;
101
+ declare const TerminalViewerHeader: <T extends Terminal | VirtualDomTerminal = Terminal | VirtualDomTerminal>({ placeholder, defaultValue, clearable, refreshable, loading, activeTitleIndex, titles, searchResult, inputAddonBefore, inputAddonAfter, icons, onTitleChange, onSearchPrev, onSearchNext, onSearchChange, onSearchClear, onRefresh, terminalRef, allCollapsed, collapseAction, }: TerminalViewerHeaderProps<T>) => React.JSX.Element;
88
102
  export default TerminalViewerHeader;
@@ -4,10 +4,11 @@ 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 { CloseCircleFilled, DownOutlined, LoadingOutlined, ReloadOutlined, SearchOutlined, UpOutlined } from '@ant-design/icons';
7
8
  import React, { useCallback, useEffect, useRef, useState } from 'react';
8
- import { CloseCircleFilled, SearchOutlined, UpOutlined, DownOutlined, ReloadOutlined, LoadingOutlined } from '@ant-design/icons';
9
9
  import "./index.less";
10
10
  var TerminalViewerHeader = function TerminalViewerHeader(_ref) {
11
+ var _terminalRef$current, _terminalRef$current$;
11
12
  var _ref$placeholder = _ref.placeholder,
12
13
  placeholder = _ref$placeholder === void 0 ? '请输入' : _ref$placeholder,
13
14
  defaultValue = _ref.defaultValue,
@@ -29,7 +30,10 @@ var TerminalViewerHeader = function TerminalViewerHeader(_ref) {
29
30
  onSearchNext = _ref.onSearchNext,
30
31
  onSearchChange = _ref.onSearchChange,
31
32
  onSearchClear = _ref.onSearchClear,
32
- onRefresh = _ref.onRefresh;
33
+ onRefresh = _ref.onRefresh,
34
+ terminalRef = _ref.terminalRef,
35
+ allCollapsed = _ref.allCollapsed,
36
+ collapseAction = _ref.collapseAction;
33
37
  var _useState = useState(defaultValue || ''),
34
38
  _useState2 = _slicedToArray(_useState, 2),
35
39
  value = _useState2[0],
@@ -51,6 +55,7 @@ var TerminalViewerHeader = function TerminalViewerHeader(_ref) {
51
55
  onSearchNext(value || '');
52
56
  }
53
57
  };
58
+ var termInstance = terminalRef === null || terminalRef === void 0 || (_terminalRef$current = terminalRef.current) === null || _terminalRef$current === void 0 || (_terminalRef$current$ = _terminalRef$current.terminal) === null || _terminalRef$current$ === void 0 ? void 0 : _terminalRef$current$.call(_terminalRef$current);
54
59
  var handleSearchClear = function handleSearchClear(e) {
55
60
  setValue('');
56
61
  if (onSearchClear instanceof Function) {
@@ -99,7 +104,7 @@ var TerminalViewerHeader = function TerminalViewerHeader(_ref) {
99
104
  onClick: loading ? undefined : onRefresh
100
105
  }, loading ? (icons === null || icons === void 0 ? void 0 : icons.loading) || /*#__PURE__*/React.createElement(LoadingOutlined, null) : (icons === null || icons === void 0 ? void 0 : icons.refresh) || /*#__PURE__*/React.createElement(ReloadOutlined, null)), /*#__PURE__*/React.createElement("div", {
101
106
  className: "terminal-viewer-input-wrapper"
102
- }, /*#__PURE__*/React.createElement("input", {
107
+ }, (icons === null || icons === void 0 ? void 0 : icons.search) || /*#__PURE__*/React.createElement(SearchOutlined, null), /*#__PURE__*/React.createElement("input", {
103
108
  ref: inputRef,
104
109
  type: "text",
105
110
  value: value,
@@ -124,6 +129,6 @@ var TerminalViewerHeader = function TerminalViewerHeader(_ref) {
124
129
  }, (icons === null || icons === void 0 ? void 0 : icons.up) || /*#__PURE__*/React.createElement(UpOutlined, null)), /*#__PURE__*/React.createElement("span", {
125
130
  className: "input-suffix-search-tool",
126
131
  onClick: handleSearchNext
127
- }, (icons === null || icons === void 0 ? void 0 : icons.down) || /*#__PURE__*/React.createElement(DownOutlined, null)), (icons === null || icons === void 0 ? void 0 : icons.search) || /*#__PURE__*/React.createElement(SearchOutlined, null))), inputAddonAfter));
132
+ }, (icons === null || icons === void 0 ? void 0 : icons.down) || /*#__PURE__*/React.createElement(DownOutlined, null)))), inputAddonAfter, termInstance && (collapseAction === null || collapseAction === void 0 ? void 0 : collapseAction(termInstance, !!allCollapsed))));
128
133
  };
129
134
  export default TerminalViewerHeader;
@@ -63,6 +63,12 @@
63
63
  display: flex;
64
64
  }
65
65
  }
66
+
67
+ .anticon-search {
68
+ margin-right: 8px;
69
+ color: #fff;
70
+ font-size: 16px;
71
+ }
66
72
  }
67
73
 
68
74
  input.terminal-viewer-input {
@@ -95,10 +101,6 @@ input.terminal-viewer-input {
95
101
  flex-shrink: 0;
96
102
  align-items: center;
97
103
 
98
- .anticon-search {
99
- font-size: 16px;
100
- }
101
-
102
104
  > * {
103
105
  margin-left: 8px;
104
106
  }
@@ -1,5 +1,5 @@
1
+ import { FullscreenExitOutlined, FullscreenOutlined, VerticalAlignBottomOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
1
2
  import React from 'react';
2
- import { FullscreenOutlined, FullscreenExitOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined } from '@ant-design/icons';
3
3
  import "./index.less";
4
4
  var TerminalViewerToolBar = function TerminalViewerToolBar(_ref) {
5
5
  var className = _ref.className,
@@ -1,3 +1,4 @@
1
+ /// <reference types="@xterm/xterm" />
1
2
  import React from 'react';
2
3
  import { IHighlightOptions } from '../Addon/HighlightAddon';
3
4
  import type { SearcherRef } from '../Addon/WorkerLog/types';
@@ -62,6 +63,10 @@ export interface TerminalViewerVirtualDomProps {
62
63
  * @description.zh-CN 加载状态变更后的回调
63
64
  */
64
65
  onLoading?: (loading: boolean) => void;
66
+ /**
67
+ * @description.zh-CN 折叠状态变更后的回调
68
+ */
69
+ onCollapseStatusChange?: (allCollapsed: boolean) => void;
65
70
  }
66
71
  /**
67
72
  * 置顶时:滚动到第一个分组
@@ -69,5 +74,5 @@ export interface TerminalViewerVirtualDomProps {
69
74
  * 最后一个分组折叠时,在折叠之前,添加底部空间
70
75
  * 最后一个分组展开时,在展开之前,删除底部空间
71
76
  */
72
- declare const ReactVirtuoso: React.ForwardRefExoticComponent<TerminalViewerVirtualDomProps & React.RefAttributes<TerminalRef | undefined>>;
77
+ declare const ReactVirtuoso: React.ForwardRefExoticComponent<TerminalViewerVirtualDomProps & React.RefAttributes<TerminalRef<import("src").Terminal | VirtualDomTerminal> | undefined>>;
73
78
  export default ReactVirtuoso;
@@ -70,7 +70,8 @@ var ReactVirtuoso = /*#__PURE__*/forwardRef(function (_ref, ref) {
70
70
  highlightOptions = _ref.highlightOptions,
71
71
  extraOptions = _ref.extraOptions,
72
72
  onLoading = _ref.onLoading,
73
- onAddonReady = _ref.onAddonReady;
73
+ onAddonReady = _ref.onAddonReady,
74
+ onCollapseStatusChange = _ref.onCollapseStatusChange;
74
75
  var domRef = useRef(null);
75
76
  var mountedRef = useRef(false);
76
77
  var virtuosoRef = useRef(null);
@@ -116,7 +117,10 @@ var ReactVirtuoso = /*#__PURE__*/forwardRef(function (_ref, ref) {
116
117
  parserRef = _useStreamStepWorkerL.parserRef,
117
118
  stageStatsRef = _useStreamStepWorkerL.stageStatsRef,
118
119
  hasUserCollapseRef = _useStreamStepWorkerL.hasUserCollapseRef,
119
- lastCollapseRef = _useStreamStepWorkerL.lastCollapseRef;
120
+ lastCollapseRef = _useStreamStepWorkerL.lastCollapseRef,
121
+ isAllCollapsed = _useStreamStepWorkerL.isAllCollapsed,
122
+ collapseAll = _useStreamStepWorkerL.collapseAll,
123
+ expandAll = _useStreamStepWorkerL.expandAll;
120
124
  var lineNumberWidth = useMemo(function () {
121
125
  var _extraOptionsRef$curr, _domRef$current;
122
126
  if (!((_extraOptionsRef$curr = extraOptionsRef.current) !== null && _extraOptionsRef$curr !== void 0 && _extraOptionsRef$curr.showLineNumber)) {
@@ -311,6 +315,11 @@ var ReactVirtuoso = /*#__PURE__*/forwardRef(function (_ref, ref) {
311
315
  }, 16);
312
316
  }
313
317
  }, [autoScroll, logs.length, scrollToRow, searcherResult.count]);
318
+ useEffect(function () {
319
+ if (typeof onCollapseStatusChange === 'function') {
320
+ onCollapseStatusChange(isAllCollapsed);
321
+ }
322
+ }, [isAllCollapsed, onCollapseStatusChange]);
314
323
  useEffect(function () {
315
324
  if (typeof onLoading === 'function') {
316
325
  onLoading(working || loading);
@@ -392,7 +401,9 @@ var ReactVirtuoso = /*#__PURE__*/forwardRef(function (_ref, ref) {
392
401
  });
393
402
  }
394
403
  isScrollTopRef.current = false;
395
- }
404
+ },
405
+ collapseAll: collapseAll,
406
+ expandAll: expandAll
396
407
  };
397
408
  }
398
409
  };
@@ -7,6 +7,8 @@ export declare const useStreamStepWorkerLogs: (string: string, changeCallback?:
7
7
  searcherRef: import("react").MutableRefObject<SearcherRef | undefined>;
8
8
  searcherResult: SearcherResult;
9
9
  toggleStage: (groupIndex: number, count: any) => void;
10
+ collapseAll: () => void;
11
+ expandAll: () => void;
10
12
  groupCounts: number[];
11
13
  parserRef: import("react").MutableRefObject<{
12
14
  stages: Stage[];
@@ -17,5 +19,6 @@ export declare const useStreamStepWorkerLogs: (string: string, changeCallback?:
17
19
  }[]>;
18
20
  hasUserCollapseRef: import("react").MutableRefObject<boolean>;
19
21
  lastCollapseRef: import("react").MutableRefObject<boolean>;
22
+ isAllCollapsed: boolean;
20
23
  };
21
24
  export default useStreamStepWorkerLogs;
@@ -8,13 +8,15 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  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; }
9
9
  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; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ /* eslint-disable function-paren-newline */
12
+ /* eslint-disable no-param-reassign */
11
13
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
12
14
  /* eslint-disable no-plusplus */
13
15
  /* eslint-disable no-bitwise */
14
16
  /* eslint-disable max-len */
15
17
  /* eslint-disable @typescript-eslint/no-unused-vars */
16
18
  /* eslint-disable @typescript-eslint/no-explicit-any */
17
- import { useCallback, useEffect, useRef, useState } from 'react';
19
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
18
20
  import { v4 as uuidv4 } from 'uuid';
19
21
  import globalContext from "../Addon/WorkerLog/GlobalContext";
20
22
  import LogWorker from "../Addon/WorkerLog/LogWorker";
@@ -75,8 +77,34 @@ export var useStreamStepWorkerLogs = function useStreamStepWorkerLogs(string, ch
75
77
  return newCount;
76
78
  });
77
79
  }, []);
78
- /* ---------- 折叠相关逻辑 END ---------- */
79
-
80
+ // 收起全部分组
81
+ var collapseAll = useCallback(function () {
82
+ var _stageStatsRef$curren2, _parserRef$current2;
83
+ hasUserCollapseRef.current = true;
84
+ stageStatsRef.current.forEach(function (stat) {
85
+ stat.collapse = true;
86
+ });
87
+ lastCollapseRef.current = ((_stageStatsRef$curren2 = stageStatsRef.current[Number((_parserRef$current2 = parserRef.current) === null || _parserRef$current2 === void 0 ? void 0 : _parserRef$current2.stages.length) - 1]) === null || _stageStatsRef$curren2 === void 0 ? void 0 : _stageStatsRef$curren2.collapse) || false;
88
+ setGroupCounts(function (pre) {
89
+ return pre.map(function () {
90
+ return 0;
91
+ });
92
+ });
93
+ }, []);
94
+ // 展开全部分组
95
+ var expandAll = useCallback(function () {
96
+ hasUserCollapseRef.current = true;
97
+ stageStatsRef.current.forEach(function (stat) {
98
+ stat.collapse = false;
99
+ });
100
+ lastCollapseRef.current = false;
101
+ setGroupCounts(function () {
102
+ return parserRef.current.stages.map(function (_, i) {
103
+ var _stageStatsRef$curren3, _stageStatsRef$curren4;
104
+ return (_stageStatsRef$curren3 = (_stageStatsRef$curren4 = stageStatsRef.current[i]) === null || _stageStatsRef$curren4 === void 0 ? void 0 : _stageStatsRef$curren4.totalCount) !== null && _stageStatsRef$curren3 !== void 0 ? _stageStatsRef$curren3 : 0;
105
+ });
106
+ });
107
+ }, []);
80
108
  useEffect(function () {
81
109
  prefixRef.current = uuidv4();
82
110
  }, []);
@@ -182,8 +210,8 @@ export var useStreamStepWorkerLogs = function useStreamStepWorkerLogs(string, ch
182
210
  lastCollapseRef.current = false;
183
211
  }
184
212
  return stages.map(function (s, i) {
185
- var _stageStatsRef$curren2;
186
- var currentCollapseStatus = (_stageStatsRef$curren2 = stageStatsRef.current) === null || _stageStatsRef$curren2 === void 0 || (_stageStatsRef$curren2 = _stageStatsRef$curren2[i]) === null || _stageStatsRef$curren2 === void 0 ? void 0 : _stageStatsRef$curren2.collapse;
213
+ var _stageStatsRef$curren5;
214
+ var currentCollapseStatus = (_stageStatsRef$curren5 = stageStatsRef.current) === null || _stageStatsRef$curren5 === void 0 || (_stageStatsRef$curren5 = _stageStatsRef$curren5[i]) === null || _stageStatsRef$curren5 === void 0 ? void 0 : _stageStatsRef$curren5.collapse;
187
215
  // 计算实际在 flatLines 中的行数(不包含 START/END 行)
188
216
  // 使用 startIndex 和 endIndex 来计算
189
217
  var actualCount = 0;
@@ -241,17 +269,26 @@ export var useStreamStepWorkerLogs = function useStreamStepWorkerLogs(string, ch
241
269
  worker === null || worker === void 0 || worker.off('search-log-success', onSearchSuccess);
242
270
  };
243
271
  }, []);
272
+ var isAllCollapsed = useMemo(function () {
273
+ if (groupCounts.length === 0) return false;
274
+ return groupCounts.every(function (count) {
275
+ return count === 0;
276
+ });
277
+ }, [groupCounts]);
244
278
  return {
245
279
  logs: logs,
246
280
  working: working,
247
281
  searcherRef: searcherRef,
248
282
  searcherResult: searcherResult,
249
283
  toggleStage: toggleStage,
284
+ collapseAll: collapseAll,
285
+ expandAll: expandAll,
250
286
  groupCounts: groupCounts,
251
287
  parserRef: parserRef,
252
288
  stageStatsRef: stageStatsRef,
253
289
  hasUserCollapseRef: hasUserCollapseRef,
254
- lastCollapseRef: lastCollapseRef
290
+ lastCollapseRef: lastCollapseRef,
291
+ isAllCollapsed: isAllCollapsed
255
292
  };
256
293
  };
257
294
  export default useStreamStepWorkerLogs;
@@ -26,8 +26,12 @@ export interface ExtraOptions {
26
26
  export interface VirtualDomTerminal {
27
27
  scrollToTop: () => void;
28
28
  scrollToBottom: () => void;
29
+ /** 收起全部分组 */
30
+ collapseAll: () => void;
31
+ /** 展开全部分组 */
32
+ expandAll: () => void;
29
33
  }
30
- export interface TerminalRef {
34
+ export interface TerminalRef<T extends Terminal | VirtualDomTerminal = Terminal | VirtualDomTerminal> {
31
35
  el?: HTMLDivElement | null;
32
36
  refresh: () => void;
33
37
  addons?: {
@@ -37,7 +41,7 @@ export interface TerminalRef {
37
41
  highlight?: () => HighlightAddon | undefined;
38
42
  canvas?: () => CanvasAddon | undefined;
39
43
  } | undefined;
40
- terminal?: () => Terminal | VirtualDomTerminal | undefined;
44
+ terminal?: () => T | undefined;
41
45
  }
42
46
  export interface LogAfterProps {
43
47
  index: number;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { SearchResultCallback, SearcherRef, SearcherResult } from '../Addon/WorkerLog/types';
2
+ import type { SearcherRef, SearcherResult, SearchResultCallback } from '../Addon/WorkerLog/types';
3
3
  export declare const useWorkerLogs: (string: string, changeCallback?: SearchResultCallback) => {
4
4
  logs: string[];
5
5
  working: boolean;
@@ -1,10 +1,10 @@
1
- import { ITerminalOptions } from '@xterm/xterm';
1
+ import { ITerminalOptions, Terminal } from '@xterm/xterm';
2
2
  import React from 'react';
3
3
  import type { IHighlightOptions } from '../Addon/HighlightAddon';
4
4
  import type { ISearchOptions } from '../Addon/SearchAddon';
5
5
  import type { ICacheOptions } from '../Hooks/useCache';
6
6
  import type { IRemoteOptions } from '../Hooks/useRemote';
7
- import { ExtraOptions, LogAfterProps, TerminalRef } from '../types';
7
+ import { ExtraOptions, LogAfterProps, TerminalRef, VirtualDomTerminal } from '../types';
8
8
  import './index.less';
9
9
  export interface TerminalViewerProps {
10
10
  /**
@@ -180,6 +180,14 @@ export interface TerminalViewerProps {
180
180
  * @description.zh-CN 刷新后的回调函数
181
181
  */
182
182
  onRefresh?: () => void;
183
+ /**
184
+ * @description.zh-CN 折叠状态变更后的回调
185
+ */
186
+ onCollapseStatusChange?: (allCollapsed: boolean) => void;
187
+ /**
188
+ * @description.zh-CN 折叠操作
189
+ */
190
+ collapseAction?: (terminal: Terminal | VirtualDomTerminal, allCollapsed: boolean) => React.ReactNode;
183
191
  }
184
- declare const TerminalViewer: React.ForwardRefExoticComponent<Omit<TerminalViewerProps, "ref"> & React.RefAttributes<TerminalRef | undefined>>;
192
+ declare const TerminalViewer: React.ForwardRefExoticComponent<Omit<TerminalViewerProps, "ref"> & React.RefAttributes<TerminalRef<Terminal | VirtualDomTerminal> | undefined>>;
185
193
  export default TerminalViewer;
@@ -83,5 +83,5 @@ export interface TerminalViewerBodyProps {
83
83
  */
84
84
  onLoading?: (loading: boolean) => void;
85
85
  }
86
- declare const TerminalViewerBody: React.ForwardRefExoticComponent<TerminalViewerBodyProps & React.RefAttributes<TerminalRef | undefined>>;
86
+ declare const TerminalViewerBody: React.ForwardRefExoticComponent<TerminalViewerBodyProps & React.RefAttributes<TerminalRef<Terminal | import("../types").VirtualDomTerminal> | undefined>>;
87
87
  export default TerminalViewerBody;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ export interface CollapseButtonProps {
3
+ /**
4
+ * @description.zh-CN 类型:fold (折叠全部) | unfold (展开全部)
5
+ */
6
+ type: 'fold' | 'unfold';
7
+ /**
8
+ * @description.zh-CN 点击回调
9
+ */
10
+ onClick?: (e: React.MouseEvent<HTMLElement>) => void;
11
+ /**
12
+ * @description.zh-CN 提示文字
13
+ */
14
+ title?: string;
15
+ /**
16
+ * @description.zh-CN 类名
17
+ */
18
+ className?: string;
19
+ }
20
+ declare const CollapseButton: React.FC<CollapseButtonProps>;
21
+ export default CollapseButton;
@@ -1,6 +1,8 @@
1
+ import { Terminal } from '@xterm/xterm';
1
2
  import React from 'react';
3
+ import { TerminalRef, VirtualDomTerminal } from '../types';
2
4
  import './index.less';
3
- export interface TerminalViewerHeaderProps {
5
+ export interface TerminalViewerHeaderProps<T extends Terminal | VirtualDomTerminal = Terminal | VirtualDomTerminal> {
4
6
  /**
5
7
  * @description.zh-CN 搜索框 placeholder
6
8
  * @default 请输入
@@ -15,7 +17,7 @@ export interface TerminalViewerHeaderProps {
15
17
  * @description.zh-CN 是否支持清除搜索框
16
18
  * @default true
17
19
  */
18
- clearable?: string;
20
+ clearable?: boolean;
19
21
  /**
20
22
  * @description.zh-CN 是否支持刷新
21
23
  */
@@ -83,6 +85,18 @@ export interface TerminalViewerHeaderProps {
83
85
  *@description.zh-CN 点击刷新按钮后的回调
84
86
  */
85
87
  onRefresh?: (e: React.SyntheticEvent<HTMLSpanElement>) => void;
88
+ /**
89
+ * @description.zh-CN 终端实例
90
+ */
91
+ terminalRef?: React.MutableRefObject<TerminalRef<T> | undefined>;
92
+ /**
93
+ * @description.zh-CN 是否全部折叠
94
+ */
95
+ allCollapsed?: boolean;
96
+ /**
97
+ * @description.zh-CN 折叠操作
98
+ */
99
+ collapseAction?: (terminal: T, allCollapsed: boolean) => React.ReactNode;
86
100
  }
87
- declare const TerminalViewerHeader: React.FC<TerminalViewerHeaderProps>;
101
+ declare const TerminalViewerHeader: <T extends Terminal | VirtualDomTerminal = Terminal | VirtualDomTerminal>({ placeholder, defaultValue, clearable, refreshable, loading, activeTitleIndex, titles, searchResult, inputAddonBefore, inputAddonAfter, icons, onTitleChange, onSearchPrev, onSearchNext, onSearchChange, onSearchClear, onRefresh, terminalRef, allCollapsed, collapseAction, }: TerminalViewerHeaderProps<T>) => React.JSX.Element;
88
102
  export default TerminalViewerHeader;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@xterm/xterm" />
1
2
  import React from 'react';
2
3
  import { IHighlightOptions } from '../Addon/HighlightAddon';
3
4
  import type { SearcherRef } from '../Addon/WorkerLog/types';
@@ -62,6 +63,10 @@ export interface TerminalViewerVirtualDomProps {
62
63
  * @description.zh-CN 加载状态变更后的回调
63
64
  */
64
65
  onLoading?: (loading: boolean) => void;
66
+ /**
67
+ * @description.zh-CN 折叠状态变更后的回调
68
+ */
69
+ onCollapseStatusChange?: (allCollapsed: boolean) => void;
65
70
  }
66
71
  /**
67
72
  * 置顶时:滚动到第一个分组
@@ -69,5 +74,5 @@ export interface TerminalViewerVirtualDomProps {
69
74
  * 最后一个分组折叠时,在折叠之前,添加底部空间
70
75
  * 最后一个分组展开时,在展开之前,删除底部空间
71
76
  */
72
- declare const ReactVirtuoso: React.ForwardRefExoticComponent<TerminalViewerVirtualDomProps & React.RefAttributes<TerminalRef | undefined>>;
77
+ declare const ReactVirtuoso: React.ForwardRefExoticComponent<TerminalViewerVirtualDomProps & React.RefAttributes<TerminalRef<import("@xterm/xterm").Terminal | VirtualDomTerminal> | undefined>>;
73
78
  export default ReactVirtuoso;
@@ -7,6 +7,8 @@ export declare const useStreamStepWorkerLogs: (string: string, changeCallback?:
7
7
  searcherRef: import("react").MutableRefObject<SearcherRef | undefined>;
8
8
  searcherResult: SearcherResult;
9
9
  toggleStage: (groupIndex: number, count: any) => void;
10
+ collapseAll: () => void;
11
+ expandAll: () => void;
10
12
  groupCounts: number[];
11
13
  parserRef: import("react").MutableRefObject<{
12
14
  stages: Stage[];
@@ -17,5 +19,6 @@ export declare const useStreamStepWorkerLogs: (string: string, changeCallback?:
17
19
  }[]>;
18
20
  hasUserCollapseRef: import("react").MutableRefObject<boolean>;
19
21
  lastCollapseRef: import("react").MutableRefObject<boolean>;
22
+ isAllCollapsed: boolean;
20
23
  };
21
24
  export default useStreamStepWorkerLogs;