react-terminal-viewer-cicd 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +181 -0
  2. package/dist/esm/Addon/EventEmiter.d.ts +18 -0
  3. package/dist/esm/Addon/EventEmiter.js +64 -0
  4. package/dist/esm/Addon/HighlightAddon.d.ts +26 -0
  5. package/dist/esm/Addon/HighlightAddon.js +188 -0
  6. package/dist/esm/Addon/SearchAddon.d.ts +140 -0
  7. package/dist/esm/Addon/SearchAddon.js +797 -0
  8. package/dist/esm/Addon/WorkerLog/GlobalContext.d.ts +10 -0
  9. package/dist/esm/Addon/WorkerLog/GlobalContext.js +37 -0
  10. package/dist/esm/Addon/WorkerLog/LimitMap.d.ts +14 -0
  11. package/dist/esm/Addon/WorkerLog/LimitMap.js +54 -0
  12. package/dist/esm/Addon/WorkerLog/LogWorker.d.ts +2 -0
  13. package/dist/esm/Addon/WorkerLog/LogWorker.js +13 -0
  14. package/dist/esm/Addon/WorkerLog/Logs.d.ts +21 -0
  15. package/dist/esm/Addon/WorkerLog/Logs.js +60 -0
  16. package/dist/esm/Addon/WorkerLog/Mark.d.ts +36 -0
  17. package/dist/esm/Addon/WorkerLog/Mark.js +155 -0
  18. package/dist/esm/Addon/WorkerLog/Searcher.d.ts +16 -0
  19. package/dist/esm/Addon/WorkerLog/Searcher.js +88 -0
  20. package/dist/esm/Addon/WorkerLog/WebWokerServer.d.ts +10 -0
  21. package/dist/esm/Addon/WorkerLog/WebWokerServer.js +57 -0
  22. package/dist/esm/Addon/WorkerLog/WebWorkerClient.d.ts +13 -0
  23. package/dist/esm/Addon/WorkerLog/WebWorkerClient.js +83 -0
  24. package/dist/esm/Addon/WorkerLog/log.worker.d.ts +1 -0
  25. package/dist/esm/Addon/WorkerLog/log.worker.js +63 -0
  26. package/dist/esm/Addon/WorkerLog/types.d.ts +18 -0
  27. package/dist/esm/Addon/WorkerLog/types.js +1 -0
  28. package/dist/esm/Addon/useAddon.d.ts +9 -0
  29. package/dist/esm/Addon/useAddon.js +33 -0
  30. package/dist/esm/Hooks/useBatchProcess.d.ts +2 -0
  31. package/dist/esm/Hooks/useBatchProcess.js +47 -0
  32. package/dist/esm/Hooks/useCache.d.ts +31 -0
  33. package/dist/esm/Hooks/useCache.js +206 -0
  34. package/dist/esm/Hooks/useDebounceInput.d.ts +3 -0
  35. package/dist/esm/Hooks/useDebounceInput.js +26 -0
  36. package/dist/esm/Hooks/useLocalStore.d.ts +2 -0
  37. package/dist/esm/Hooks/useLocalStore.js +9 -0
  38. package/dist/esm/Hooks/useRemote.d.ts +30 -0
  39. package/dist/esm/Hooks/useRemote.js +398 -0
  40. package/dist/esm/Hooks/useThrottle.d.ts +2 -0
  41. package/dist/esm/Hooks/useThrottle.js +13 -0
  42. package/dist/esm/Hooks/useWorkerLogs.d.ts +9 -0
  43. package/dist/esm/Hooks/useWorkerLogs.js +162 -0
  44. package/dist/esm/TerminalViewer/index.d.ts +185 -0
  45. package/dist/esm/TerminalViewer/index.js +292 -0
  46. package/dist/esm/TerminalViewer/index.less +17 -0
  47. package/dist/esm/TerminalViewerBody/index.d.ts +87 -0
  48. package/dist/esm/TerminalViewerBody/index.js +248 -0
  49. package/dist/esm/TerminalViewerBody/index.less +51 -0
  50. package/dist/esm/TerminalViewerHeader/index.d.ts +88 -0
  51. package/dist/esm/TerminalViewerHeader/index.js +129 -0
  52. package/dist/esm/TerminalViewerHeader/index.less +143 -0
  53. package/dist/esm/TerminalViewerToolBar/index.d.ts +46 -0
  54. package/dist/esm/TerminalViewerToolBar/index.js +28 -0
  55. package/dist/esm/TerminalViewerToolBar/index.less +32 -0
  56. package/dist/esm/TerminalViewerVirtualDom/index.d.ts +71 -0
  57. package/dist/esm/TerminalViewerVirtualDom/index.js +309 -0
  58. package/dist/esm/TerminalViewerVirtualDom/index.less +68 -0
  59. package/dist/esm/index.d.ts +9 -0
  60. package/dist/esm/index.js +9 -0
  61. package/dist/esm/mock/index.d.ts +12 -0
  62. package/dist/esm/mock/index.js +98 -0
  63. package/dist/esm/types.d.ts +30 -0
  64. package/dist/esm/types.js +1 -0
  65. package/dist/worker/Addon/EventEmiter.d.ts +18 -0
  66. package/dist/worker/Addon/HighlightAddon.d.ts +26 -0
  67. package/dist/worker/Addon/SearchAddon.d.ts +140 -0
  68. package/dist/worker/Addon/WorkerLog/GlobalContext.d.ts +10 -0
  69. package/dist/worker/Addon/WorkerLog/LimitMap.d.ts +14 -0
  70. package/dist/worker/Addon/WorkerLog/LogWorker.d.ts +2 -0
  71. package/dist/worker/Addon/WorkerLog/Logs.d.ts +21 -0
  72. package/dist/worker/Addon/WorkerLog/Mark.d.ts +36 -0
  73. package/dist/worker/Addon/WorkerLog/Searcher.d.ts +16 -0
  74. package/dist/worker/Addon/WorkerLog/WebWokerServer.d.ts +10 -0
  75. package/dist/worker/Addon/WorkerLog/WebWorkerClient.d.ts +13 -0
  76. package/dist/worker/Addon/WorkerLog/log.worker.d.ts +1 -0
  77. package/dist/worker/Addon/WorkerLog/types.d.ts +18 -0
  78. package/dist/worker/Addon/useAddon.d.ts +9 -0
  79. package/dist/worker/Hooks/useBatchProcess.d.ts +2 -0
  80. package/dist/worker/Hooks/useCache.d.ts +31 -0
  81. package/dist/worker/Hooks/useDebounceInput.d.ts +3 -0
  82. package/dist/worker/Hooks/useLocalStore.d.ts +2 -0
  83. package/dist/worker/Hooks/useRemote.d.ts +30 -0
  84. package/dist/worker/Hooks/useRemote.test.d.ts +1 -0
  85. package/dist/worker/Hooks/useThrottle.d.ts +2 -0
  86. package/dist/worker/Hooks/useWorkerLogs.d.ts +9 -0
  87. package/dist/worker/TerminalViewer/index.d.ts +185 -0
  88. package/dist/worker/TerminalViewer/index.test.d.ts +1 -0
  89. package/dist/worker/TerminalViewerBody/index.d.ts +87 -0
  90. package/dist/worker/TerminalViewerBody/index.test.d.ts +1 -0
  91. package/dist/worker/TerminalViewerHeader/index.d.ts +88 -0
  92. package/dist/worker/TerminalViewerToolBar/index.d.ts +46 -0
  93. package/dist/worker/TerminalViewerVirtualDom/index.d.ts +71 -0
  94. package/dist/worker/index.d.ts +9 -0
  95. package/dist/worker/log.worker.js +2 -0
  96. package/dist/worker/log.worker.js.map +1 -0
  97. package/dist/worker/mock/index.d.ts +12 -0
  98. package/dist/worker/types.d.ts +30 -0
  99. package/package.json +97 -0
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ interface TerminalViewerToolBarProps {
4
+ /**
5
+ * @description.zh-CN 外层容器样式类名
6
+ */
7
+ className?: string;
8
+ /**
9
+ * @description.zh-CN 外层容器样式
10
+ *
11
+ */
12
+ style?: object;
13
+ /**
14
+ *@description.zh-CN 自定义图标
15
+ */
16
+ icons?: {
17
+ top?: React.ReactNode;
18
+ bottom?: React.ReactNode;
19
+ fullScreen?: React.ReactNode;
20
+ fullScreenExit?: React.ReactNode;
21
+ };
22
+ /**
23
+ * @description.zh-CN 是否为全屏模式
24
+ * @default false
25
+ */
26
+ fullScreen?: boolean;
27
+ /**
28
+ * @description.zh-CN 是否显示全屏图标
29
+ * @default true
30
+ */
31
+ showFullScreen?: boolean;
32
+ /** *
33
+ * @description.zh.CN 点击滚动到顶部按钮的回调
34
+ */
35
+ onScrollTop?: (e: React.SyntheticEvent<HTMLDivElement>) => void;
36
+ /**
37
+ * @description.zh.CN 点击滚动到底部按钮的回调
38
+ */
39
+ onScrollBottom?: (e: React.SyntheticEvent<HTMLDivElement>) => void;
40
+ /**
41
+ * @description.zh.CN 点击全屏/取消全屏按钮的回调
42
+ */
43
+ onFullScreen?: (e: React.SyntheticEvent<HTMLDivElement>) => void;
44
+ }
45
+ declare const TerminalViewerToolBar: React.FC<TerminalViewerToolBarProps>;
46
+ export default TerminalViewerToolBar;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { FullscreenOutlined, FullscreenExitOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined } from '@ant-design/icons';
3
+ import "./index.less";
4
+ var TerminalViewerToolBar = function TerminalViewerToolBar(_ref) {
5
+ var className = _ref.className,
6
+ style = _ref.style,
7
+ icons = _ref.icons,
8
+ fullScreen = _ref.fullScreen,
9
+ _ref$showFullScreen = _ref.showFullScreen,
10
+ showFullScreen = _ref$showFullScreen === void 0 ? true : _ref$showFullScreen,
11
+ onScrollTop = _ref.onScrollTop,
12
+ onScrollBottom = _ref.onScrollBottom,
13
+ onFullScreen = _ref.onFullScreen;
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ className: ['terminal-viewer-toolbar', className].filter(Boolean).join(' '),
16
+ style: style
17
+ }, /*#__PURE__*/React.createElement("div", {
18
+ className: "terminal-viewer-toolbar-button",
19
+ onClick: onScrollTop
20
+ }, (icons === null || icons === void 0 ? void 0 : icons.top) || /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null)), /*#__PURE__*/React.createElement("div", {
21
+ className: "terminal-viewer-toolbar-button",
22
+ onClick: onScrollBottom
23
+ }, (icons === null || icons === void 0 ? void 0 : icons.bottom) || /*#__PURE__*/React.createElement(VerticalAlignBottomOutlined, null)), showFullScreen && /*#__PURE__*/React.createElement("div", {
24
+ className: "terminal-viewer-toolbar-button",
25
+ onClick: onFullScreen
26
+ }, fullScreen ? (icons === null || icons === void 0 ? void 0 : icons.fullScreenExit) || /*#__PURE__*/React.createElement(FullscreenExitOutlined, null) : (icons === null || icons === void 0 ? void 0 : icons.fullScreen) || /*#__PURE__*/React.createElement(FullscreenOutlined, null)));
27
+ };
28
+ export default TerminalViewerToolBar;
@@ -0,0 +1,32 @@
1
+ .terminal-viewer-toolbar {
2
+ position: absolute;
3
+ right: 48px;
4
+ bottom: 24px;
5
+ z-index: 1800;
6
+ display: flex;
7
+ font-size: 16px;
8
+ }
9
+
10
+ .terminal-viewer-toolbar-button {
11
+ z-index: 1900;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ width: 32px;
16
+ height: 32px;
17
+ color: #b5bbc6;
18
+ background: #30363d;
19
+ border: 1px solid rgba(140, 150, 166, 0.1);
20
+ cursor: pointer;
21
+ &:hover {
22
+ color: #fff;
23
+ }
24
+
25
+ &:first-child {
26
+ border-radius: 4px 0 0 4px;
27
+ }
28
+
29
+ &:last-child {
30
+ border-radius: 0 4px 4px 0;
31
+ }
32
+ }
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import type { ListRowProps } from 'react-virtualized';
3
+ import type { IRemoteOptions } from '../Hooks/useRemote';
4
+ import type { ICacheOptions } from '../Hooks/useCache';
5
+ import { IHighlightOptions } from '../Addon/HighlightAddon';
6
+ import type { SearcherRef } from '../Addon/WorkerLog/types';
7
+ import { VirtualDomTerminal, TerminalRef, ExtraOptions, LogAfterProps } from '../types';
8
+ import './index.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 TerminalViewerVirtualDom: React.ForwardRefExoticComponent<TerminalViewerVirtualDomProps & React.RefAttributes<TerminalRef | undefined>>;
71
+ export default TerminalViewerVirtualDom;
@@ -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, { forwardRef, useRef, useEffect, useImperativeHandle, useCallback, useMemo, createElement } from 'react';
13
+ import { CellMeasurer, CellMeasurerCache, AutoSizer } 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 "./index.less";
19
+ // eslint-disable-next-line react/display-name, max-len
20
+ var TerminalViewerVirtualDom = /*#__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 TerminalViewerVirtualDom;
@@ -0,0 +1,68 @@
1
+ .terminal-viewer-virtual-list {
2
+ padding: 16px;
3
+ color: #b5bbc6;
4
+ font-size: 13px;
5
+ font-family: Roboto Mono, Andale Mono, Consolas, Courier New, monospace;
6
+ }
7
+
8
+ .terminal-viewer-virtual-list-row {
9
+ display: inline-flex;
10
+ align-items: stretch;
11
+ overflow: visible;
12
+ }
13
+
14
+ .terminal-viewer-virtual-list-row--active {
15
+ color: #dddddd;
16
+ background: #3c4655;
17
+ .terminal-viewer-line-number,
18
+ .terminal-viewer-pre {
19
+ color: #dddddd;
20
+ }
21
+ }
22
+
23
+ .terminal-viewer-line-number,
24
+ .terminal-viewer-text-placeholder {
25
+ margin-right: 8px;
26
+ padding-right: 8px;
27
+ color: #959da5bf;
28
+ font-size: 12px;
29
+ font-family: Roboto Mono, Andale Mono, Consolas, Courier New, monospace;
30
+ line-height: 20px;
31
+ text-align: right;
32
+ }
33
+
34
+ .terminal-viewer-line-number {
35
+ display: inline-block;
36
+ flex-shrink: 0;
37
+ overflow: hidden;
38
+ white-space: nowrap;
39
+ text-overflow: ellipsis;
40
+ }
41
+ .terminal-viewer-text-placeholder {
42
+ position: absolute;
43
+ visibility: hidden;
44
+ }
45
+
46
+ .terminal-viewer-hl-mark {
47
+ color: #000000;
48
+ background: #ffff54;
49
+ }
50
+
51
+ .terminal-viewer-hl-marked {
52
+ background: #ff9540;
53
+ }
54
+
55
+ .terminal-viewer-pre {
56
+ display: inline-block;
57
+ flex-grow: 1;
58
+ margin: 0;
59
+ padding: 0;
60
+ overflow: hidden;
61
+ line-height: 20px;
62
+ white-space: pre-wrap;
63
+ word-wrap: break-word;
64
+ word-break: break-all;
65
+ background-color: #f5f5f5;
66
+ border: none;
67
+ border-radius: 0;
68
+ }
@@ -0,0 +1,9 @@
1
+ import { Terminal, ITerminalOptions } from 'xterm';
2
+ import TerminalViewer from './TerminalViewer';
3
+ import TerminalViewerHeader from './TerminalViewerHeader';
4
+ import TerminalViewerBody from './TerminalViewerBody';
5
+ import TerminalViewerVirtualDom from './TerminalViewerVirtualDom';
6
+ import TerminalViewerToolBar from './TerminalViewerToolBar';
7
+ export { Terminal, ITerminalOptions };
8
+ export { TerminalViewerHeader, TerminalViewerBody, TerminalViewerVirtualDom, TerminalViewerToolBar, };
9
+ export default TerminalViewer;
@@ -0,0 +1,9 @@
1
+ import { Terminal, ITerminalOptions } from 'xterm';
2
+ import TerminalViewer from "./TerminalViewer";
3
+ import TerminalViewerHeader from "./TerminalViewerHeader";
4
+ import TerminalViewerBody from "./TerminalViewerBody";
5
+ import TerminalViewerVirtualDom from "./TerminalViewerVirtualDom";
6
+ import TerminalViewerToolBar from "./TerminalViewerToolBar";
7
+ export { Terminal, ITerminalOptions };
8
+ export { TerminalViewerHeader, TerminalViewerBody, TerminalViewerVirtualDom, TerminalViewerToolBar };
9
+ export default TerminalViewer;
@@ -0,0 +1,12 @@
1
+ export declare function loadTest(): string;
2
+ export declare function loadAdvancedTest(): string;
3
+ export declare function loadCustomHighLightTest(random?: boolean): string;
4
+ export declare function fetchCustomHighLightTest(start?: number): Promise<unknown>;
5
+ export declare function remoteFetch(key?: number): Promise<unknown>;
6
+ export declare function cacheFetch(key?: number): Promise<unknown>;
7
+ declare const _default: {
8
+ loadTest: typeof loadTest;
9
+ remoteFetch: typeof remoteFetch;
10
+ cacheFetch: typeof cacheFetch;
11
+ };
12
+ export default _default;