react-terminal-viewer-cicd 3.0.0-beta.2 → 3.0.0-beta.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 (41) hide show
  1. package/dist/esm/Addon/WorkerLog/LogWorker.js +1 -1
  2. package/dist/esm/Addon/WorkerLog/Logs.d.ts +2 -2
  3. package/dist/esm/Addon/WorkerLog/Searcher.d.ts +9 -7
  4. package/dist/esm/Addon/WorkerLog/Searcher.js +20 -8
  5. package/dist/esm/Hooks/useRemote.d.ts +1 -1
  6. package/dist/esm/Hooks/useRemote.js +3 -2
  7. package/dist/esm/TerminalViewerVirtualDom/HumenTime.d.ts +14 -0
  8. package/dist/esm/TerminalViewerVirtualDom/HumenTime.js +111 -0
  9. package/dist/esm/TerminalViewerVirtualDom/LogParser.d.ts +23 -0
  10. package/dist/esm/TerminalViewerVirtualDom/LogParser.js +167 -0
  11. package/dist/esm/TerminalViewerVirtualDom/StatusIcon.d.ts +4 -0
  12. package/dist/esm/TerminalViewerVirtualDom/StatusIcon.js +33 -0
  13. package/dist/esm/TerminalViewerVirtualDom/index.d.ts +67 -2
  14. package/dist/esm/TerminalViewerVirtualDom/index.js +319 -3
  15. package/dist/esm/TerminalViewerVirtualDom/{virtuoso.less → index.less} +44 -5
  16. package/dist/esm/TerminalViewerVirtualDom/useStreamStepWorkerLogs.d.ts +13 -0
  17. package/dist/esm/TerminalViewerVirtualDom/useStreamStepWorkerLogs.js +192 -0
  18. package/dist/esm/TerminalViewerVirtualDom/watting.svg +1 -0
  19. package/dist/esm/mock/index.d.ts +2 -0
  20. package/dist/esm/mock/index.js +108 -1
  21. package/dist/esm/types.d.ts +10 -0
  22. package/dist/worker/log.worker.dev.js +3291 -0
  23. package/dist/worker/log.worker.dev.js.map +1 -0
  24. package/dist/worker/log.worker.js +1 -1
  25. package/dist/worker/log.worker.js.map +1 -1
  26. package/dist/worker/src/Addon/WorkerLog/Logs.d.ts +2 -2
  27. package/dist/worker/src/Addon/WorkerLog/Searcher.d.ts +9 -7
  28. package/dist/worker/src/Hooks/useRemote.d.ts +1 -1
  29. package/dist/worker/src/TerminalViewerVirtualDom/HumenTime.d.ts +14 -0
  30. package/dist/worker/src/TerminalViewerVirtualDom/LogParser.d.ts +23 -0
  31. package/dist/worker/src/TerminalViewerVirtualDom/StatusIcon.d.ts +4 -0
  32. package/dist/worker/src/TerminalViewerVirtualDom/index.d.ts +67 -2
  33. package/dist/worker/src/TerminalViewerVirtualDom/parsePipelineLogs.d.ts +21 -0
  34. package/dist/worker/src/TerminalViewerVirtualDom/useStreamStepWorkerLogs.d.ts +13 -0
  35. package/dist/worker/src/mock/index.d.ts +2 -0
  36. package/dist/worker/src/types.d.ts +10 -0
  37. package/package.json +1 -1
  38. package/dist/esm/TerminalViewerVirtualDom/ReactVirtualized.d.ts +0 -71
  39. package/dist/esm/TerminalViewerVirtualDom/ReactVirtualized.js +0 -309
  40. package/dist/esm/TerminalViewerVirtualDom/ReactVirtuoso.d.ts +0 -67
  41. package/dist/esm/TerminalViewerVirtualDom/ReactVirtuoso.js +0 -271
@@ -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.2" || '0.0.0';
4
+ var version = "3.0.0-beta.4" || '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'
@@ -13,8 +13,8 @@ export default class Logs {
13
13
  mark(keyword: string, hlIndex?: number, options?: ISearchOptions | undefined): {
14
14
  count: number;
15
15
  map: {
16
- [key: string]: string;
17
- [key: number]: string;
16
+ [key: string]: string | Record<string, string>;
17
+ [key: number]: string | Record<string, string>;
18
18
  };
19
19
  markedKey: number;
20
20
  };
@@ -1,15 +1,17 @@
1
1
  import { ISearchOptions } from '../SearchAddon';
2
+ export interface IOptions {
3
+ markClassName?: string;
4
+ markedClassName?: string;
5
+ calculateSearchText?: (line: Record<string, string>) => string;
6
+ }
2
7
  export default class Searcher {
3
8
  private options;
4
- constructor(options?: {
5
- markClassName: string;
6
- markedClassName: string;
7
- });
8
- search(keyword: string, logs: Array<string>, hlIndex?: number, options?: ISearchOptions | undefined): {
9
+ constructor(options?: IOptions);
10
+ search(keyword: string, logs: Array<string | Record<string, string>>, hlIndex?: number, options?: ISearchOptions | undefined): {
9
11
  count: number;
10
12
  map: {
11
- [key: string]: string;
12
- [key: number]: string;
13
+ [key: string]: string | Record<string, string>;
14
+ [key: number]: string | Record<string, string>;
13
15
  };
14
16
  markedKey: number;
15
17
  };
@@ -1,4 +1,6 @@
1
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 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; }
3
+ 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; }
2
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
5
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -10,14 +12,13 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
10
12
  import Mark from "./Mark";
11
13
  var MAX_COUNT = 1000;
12
14
  var Searcher = /*#__PURE__*/function () {
13
- function Searcher() {
14
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
15
- markClassName: 'terminal-viewer-hl-mark',
16
- markedClassName: 'terminal-viewer-hl-mark terminal-viewer-hl-marked'
17
- };
15
+ function Searcher(options) {
18
16
  _classCallCheck(this, Searcher);
19
17
  _defineProperty(this, "options", void 0);
20
- this.options = options;
18
+ this.options = _objectSpread({
19
+ markClassName: 'terminal-viewer-hl-mark',
20
+ markedClassName: 'terminal-viewer-hl-mark terminal-viewer-hl-marked'
21
+ }, options || {});
21
22
  }
22
23
  _createClass(Searcher, [{
23
24
  key: "search",
@@ -34,7 +35,8 @@ var Searcher = /*#__PURE__*/function () {
34
35
  }
35
36
  var _this$options = this.options,
36
37
  markClassName = _this$options.markClassName,
37
- markedClassName = _this$options.markedClassName;
38
+ markedClassName = _this$options.markedClassName,
39
+ calculateSearchText = _this$options.calculateSearchText;
38
40
  var style = {
39
41
  color: options === null || options === void 0 || (_options$decorations = options.decorations) === null || _options$decorations === void 0 ? void 0 : _options$decorations.matchForegroundColor,
40
42
  background: options === null || options === void 0 || (_options$decorations2 = options.decorations) === null || _options$decorations2 === void 0 ? void 0 : _options$decorations2.matchBackground,
@@ -51,7 +53,17 @@ var Searcher = /*#__PURE__*/function () {
51
53
  if (count >= MAX_COUNT) {
52
54
  break;
53
55
  }
54
- var text = logs[i] || '';
56
+ var _line = logs[i];
57
+ var text = '';
58
+ // 对象,用 calculateSearchText 取值
59
+ if (_typeof(_line) === 'object') {
60
+ text = (calculateSearchText === null || calculateSearchText === void 0 ? void 0 : calculateSearchText(_line)) || '';
61
+ }
62
+ // string,直接使用
63
+ if (typeof _line === 'string') {
64
+ text = _line;
65
+ }
66
+ // 执行匹配查询逻辑
55
67
  if (!text.toLowerCase().includes(keyword.toLowerCase())) {
56
68
  // eslint-disable-next-line no-continue
57
69
  continue;
@@ -8,7 +8,7 @@ export interface IRemoteOptions {
8
8
  retry?: number;
9
9
  enableBatch?: boolean;
10
10
  }
11
- export type UseRemoteHooks = (defaultData: string, callback?: (string: string) => void, options?: IRemoteOptions | undefined, cacheOptions?: ICacheOptions) => {
11
+ export type UseRemoteHooks = (defaultData: string, callback?: (string: string) => void, options?: IRemoteOptions | undefined, cacheOptions?: ICacheOptions, incremental?: boolean) => {
12
12
  data: string;
13
13
  refresh: () => void;
14
14
  cacheStore: LocalForage;
@@ -312,7 +312,7 @@ export var useSequenceFetch = function useSequenceFetch(fetch, callback, options
312
312
  cacheStore: store
313
313
  };
314
314
  };
315
- var useRemote = function useRemote(defaultData, callback, options, cacheOptions) {
315
+ var useRemote = function useRemote(defaultData, callback, options, cacheOptions, incremental) {
316
316
  var _ref5 = options !== null && options !== void 0 ? options : {},
317
317
  fetch = _ref5.fetch,
318
318
  _ref5$timeout = _ref5.timeout,
@@ -334,7 +334,8 @@ var useRemote = function useRemote(defaultData, callback, options, cacheOptions)
334
334
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
335
335
  while (1) switch (_context6.prev = _context6.next) {
336
336
  case 0:
337
- setData(function (p) {
337
+ // 增量模式时,只返回当前结果
338
+ setData(incremental ? result : function (p) {
338
339
  return p + result;
339
340
  });
340
341
  incrementalRef.current = result;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export declare const shortDuration: (value: number | string, unit?: 'years' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds') => string;
3
+ type HumenTimeProps = {
4
+ serverTime?: string;
5
+ time?: number;
6
+ convert?: boolean;
7
+ offsetTime?: number;
8
+ timing?: boolean;
9
+ startTime?: string;
10
+ endTime?: string;
11
+ className?: string;
12
+ };
13
+ declare const _default: React.NamedExoticComponent<HumenTimeProps>;
14
+ export default _default;
@@ -0,0 +1,111 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ /* eslint-disable @typescript-eslint/no-empty-function */
8
+ import React, { memo, useEffect, useRef, useState } from 'react';
9
+ export var shortDuration = function shortDuration(value, unit) {
10
+ // 转换为毫秒
11
+ var ms = typeof value === 'string' ? parseFloat(value) : value;
12
+ var unitToMs = {
13
+ years: 365 * 24 * 60 * 60 * 1000,
14
+ months: 30 * 24 * 60 * 60 * 1000,
15
+ // 近似值
16
+ weeks: 7 * 24 * 60 * 60 * 1000,
17
+ days: 24 * 60 * 60 * 1000,
18
+ hours: 60 * 60 * 1000,
19
+ minutes: 60 * 1000,
20
+ seconds: 1000,
21
+ milliseconds: 1
22
+ };
23
+ if (unit && unitToMs[unit]) {
24
+ ms *= unitToMs[unit];
25
+ }
26
+
27
+ // 计算各个时间单位
28
+ var y = Math.floor(ms / unitToMs.years);
29
+ ms %= unitToMs.years;
30
+ var M = Math.floor(ms / unitToMs.months);
31
+ ms %= unitToMs.months;
32
+ var d = Math.floor(ms / unitToMs.days);
33
+ ms %= unitToMs.days;
34
+ var h = Math.floor(ms / unitToMs.hours);
35
+ ms %= unitToMs.hours;
36
+ var m = Math.floor(ms / unitToMs.minutes);
37
+ ms %= unitToMs.minutes;
38
+ var s = Math.floor(ms / unitToMs.seconds);
39
+
40
+ // 构建字符串
41
+ var str = '';
42
+ if (y) str += "".concat(y, "Y ");
43
+ if (M) str += "".concat(M, "M ");
44
+ if (d) str += "".concat(d, "d ");
45
+ if (h) str += "".concat(h, "h ");
46
+ if (m) str += "".concat(m, "m ");
47
+ str += "".concat(s, "s");
48
+ return str;
49
+ };
50
+ var HumenTime = function HumenTime(_ref) {
51
+ var time = _ref.time,
52
+ _ref$convert = _ref.convert,
53
+ convert = _ref$convert === void 0 ? true : _ref$convert,
54
+ _ref$offsetTime = _ref.offsetTime,
55
+ offsetTime = _ref$offsetTime === void 0 ? 0 : _ref$offsetTime,
56
+ startTime = _ref.startTime,
57
+ endTime = _ref.endTime,
58
+ _ref$timing = _ref.timing,
59
+ timing = _ref$timing === void 0 ? false : _ref$timing,
60
+ serverTime = _ref.serverTime;
61
+ var _useState = useState(0),
62
+ _useState2 = _slicedToArray(_useState, 2),
63
+ computedTime = _useState2[0],
64
+ setComputedTime = _useState2[1];
65
+ var serverTimeRef = useRef(serverTime);
66
+ useEffect(function () {
67
+ serverTimeRef.current = serverTime;
68
+ }, [serverTime]);
69
+ useEffect(function () {
70
+ var timer;
71
+ var localStartTime = Number.isFinite(Number(startTime)) ? startTime : '-';
72
+ if (!Number.isFinite(Number(localStartTime))) {
73
+ setComputedTime('-');
74
+ return function () {};
75
+ }
76
+ var convertTime = function convertTime() {
77
+ // 优先取服务器端时间
78
+ var localEndTime = Number.isFinite(Number(endTime)) && !timing ? endTime : new Date().getTime() + offsetTime;
79
+
80
+ // 运行中的 job ,使用server端的时间来计算
81
+ if (serverTimeRef.current) {
82
+ var baseTime = (Number(serverTimeRef.current) - Number(localStartTime)) / 1000;
83
+ setComputedTime(function (pre) {
84
+ return Number(pre) > 0 ? Number(pre) + 1 : baseTime;
85
+ });
86
+ } else {
87
+ setComputedTime((Number(localEndTime) - Number(localStartTime)) / 1000);
88
+ }
89
+ };
90
+ // 定时计算
91
+ if (timing) {
92
+ timer = setInterval(function () {
93
+ convertTime();
94
+ }, 1000);
95
+ }
96
+ // 初始化计算
97
+ convertTime();
98
+ return function () {
99
+ clearInterval(timer);
100
+ };
101
+ }, [endTime, startTime, offsetTime, timing]);
102
+ if (!time) {
103
+ return /*#__PURE__*/React.createElement("div", {
104
+ className: "terminal-viewer-virtuoso-list-row-step-time"
105
+ }, /*#__PURE__*/React.createElement("span", null, Number.isFinite(Number(computedTime)) && convert ? shortDuration(Number(computedTime), 'seconds') : Number(computedTime), !Number.isFinite(Number(computedTime)) && '-'));
106
+ }
107
+ return /*#__PURE__*/React.createElement("div", {
108
+ className: "terminal-viewer-virtuoso-list-row-step-time"
109
+ }, /*#__PURE__*/React.createElement("span", null, convert ? shortDuration(time, 'seconds') : time));
110
+ };
111
+ export default /*#__PURE__*/memo(HumenTime);
@@ -0,0 +1,23 @@
1
+ export interface FlatLine {
2
+ type: 'start' | 'end' | 'log';
3
+ text: string;
4
+ }
5
+ export interface Stage {
6
+ stepId: string;
7
+ status: string;
8
+ startTime: string;
9
+ name: string;
10
+ startIndex: number;
11
+ endIndex?: number;
12
+ endStatus?: string;
13
+ endTime?: string;
14
+ logs: FlatLine[];
15
+ }
16
+ declare class LogParser {
17
+ stages: Stage[];
18
+ currentStage: Stage | null;
19
+ flatLines: FlatLine[];
20
+ push(line: string, lineIndex: number): void;
21
+ parse(logs: string[]): void;
22
+ }
23
+ export default LogParser;
@@ -0,0 +1,167 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ 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; }
6
+ 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; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ 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; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ 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); }
14
+ /* eslint-disable no-continue */
15
+ /* eslint-disable no-plusplus */
16
+ // 阶段结构
17
+ var LogParser = /*#__PURE__*/function () {
18
+ function LogParser() {
19
+ _classCallCheck(this, LogParser);
20
+ _defineProperty(this, "stages", []);
21
+ // 所有阶段数据
22
+ _defineProperty(this, "currentStage", null);
23
+ // 当前正在解析入的阶段
24
+ _defineProperty(this, "flatLines", []);
25
+ }
26
+ _createClass(LogParser, [{
27
+ key: "push",
28
+ value:
29
+ // 扁平化行数组(最终给 Virtuoso)
30
+
31
+ function push(line, lineIndex) {
32
+ console.log('>>> LogParser >>34', lineIndex);
33
+ // START_stepId_status_startTime_stepName
34
+ if (line.startsWith('START_')) {
35
+ var _line$split = line.split('_'),
36
+ _line$split2 = _slicedToArray(_line$split, 5),
37
+ stepId = _line$split2[1],
38
+ status = _line$split2[2],
39
+ startTime = _line$split2[3],
40
+ name = _line$split2[4];
41
+ this.currentStage = {
42
+ stepId: stepId,
43
+ status: status,
44
+ startTime: startTime,
45
+ name: name,
46
+ startIndex: lineIndex,
47
+ endIndex: undefined,
48
+ logs: []
49
+ };
50
+ this.flatLines.push({
51
+ type: 'start',
52
+ text: line
53
+ });
54
+ return;
55
+ }
56
+
57
+ // END_stepId_status_endTime_stepName
58
+ if (line.startsWith('END_')) {
59
+ this.flatLines.push({
60
+ type: 'end',
61
+ text: line
62
+ });
63
+ if (this.currentStage) {
64
+ var _line$split3 = line.split('_'),
65
+ _line$split4 = _slicedToArray(_line$split3, 4),
66
+ endStatus = _line$split4[2],
67
+ endTime = _line$split4[3];
68
+ this.currentStage.endStatus = endStatus;
69
+ this.currentStage.endTime = endTime;
70
+ this.currentStage.endIndex = lineIndex;
71
+ this.stages.push(this.currentStage);
72
+ this.currentStage = null;
73
+ }
74
+ return;
75
+ }
76
+
77
+ // 普通行
78
+ this.flatLines.push({
79
+ type: 'log',
80
+ text: line
81
+ });
82
+ }
83
+ }, {
84
+ key: "parse",
85
+ value: function parse(logs) {
86
+ if (!logs || !Array.isArray(logs)) {
87
+ return;
88
+ }
89
+ for (var i = 0; i < logs.length; i++) {
90
+ var line = logs[i];
91
+ // START_stepId_status_startTime_stepName
92
+ if (line.startsWith('START_')) {
93
+ // 如果你需要解析 stepId 等,可以在这里 split 一次
94
+ var _line$split5 = line.split('_'),
95
+ _line$split6 = _slicedToArray(_line$split5, 5),
96
+ stepId = _line$split6[1],
97
+ status = _line$split6[2],
98
+ startTime = _line$split6[3],
99
+ name = _line$split6[4];
100
+ this.currentStage = {
101
+ stepId: stepId,
102
+ status: status,
103
+ startTime: startTime,
104
+ name: name,
105
+ startIndex: i,
106
+ endIndex: undefined,
107
+ logs: []
108
+ };
109
+ this.flatLines.push({
110
+ type: 'start',
111
+ text: line
112
+ });
113
+ // TODO: 存储阶段首行
114
+ this.currentStage.logs.push({
115
+ type: 'start',
116
+ text: line
117
+ });
118
+ continue;
119
+ }
120
+
121
+ // END_stepId_status_endTime_stepName
122
+ if (line.startsWith('END_')) {
123
+ if (this.currentStage) {
124
+ // TODO: 存储阶段最后一行
125
+ this.currentStage.logs.push({
126
+ type: 'end',
127
+ text: line
128
+ });
129
+ var _line$split7 = line.split('_'),
130
+ _line$split8 = _slicedToArray(_line$split7, 4),
131
+ endStatus = _line$split8[2],
132
+ endTime = _line$split8[3];
133
+ this.currentStage.endTime = endTime;
134
+ this.currentStage.endStatus = endStatus;
135
+ this.currentStage.endIndex = i;
136
+ this.stages.push(this.currentStage);
137
+ this.currentStage = null;
138
+ }
139
+ this.flatLines.push({
140
+ type: 'end',
141
+ text: line
142
+ });
143
+ continue;
144
+ }
145
+
146
+ // 普通日志行
147
+ this.flatLines.push({
148
+ type: 'log',
149
+ text: line
150
+ });
151
+ // 普通日志行
152
+ if (this.currentStage) {
153
+ this.currentStage.logs.push({
154
+ type: 'log',
155
+ text: line
156
+ });
157
+ }
158
+ }
159
+ if (this.currentStage) {
160
+ this.stages.push(this.currentStage);
161
+ this.currentStage = null;
162
+ }
163
+ }
164
+ }]);
165
+ return LogParser;
166
+ }();
167
+ export default LogParser;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const Success: React.FC;
3
+ declare const _default: Record<string, React.ReactElement<any, string | React.JSXElementConstructor<any>>>;
4
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import { Loading3QuartersOutlined } from '@ant-design/icons';
2
+ import React from 'react';
3
+ export var Success = function Success() {
4
+ return /*#__PURE__*/React.createElement("svg", {
5
+ id: "check-circle-filled-default",
6
+ style: {
7
+ width: '16px',
8
+ height: '16px'
9
+ },
10
+ className: "ruyi-icon ruyi-icon-check-circle-filled-default",
11
+ xmlns: "http://www.w3.org/2000/svg",
12
+ width: "16",
13
+ height: "16",
14
+ viewBox: "0 0 16 16"
15
+ }, /*#__PURE__*/React.createElement("g", {
16
+ fill: "none"
17
+ }, /*#__PURE__*/React.createElement("path", {
18
+ d: "M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15Z",
19
+ fill: "#00A66E"
20
+ }), /*#__PURE__*/React.createElement("path", {
21
+ d: "M4.5 8.2065L5.2065 7.5L7 9.293L10.7925 5.5L11.5 6.2075L7 10.707L4.5 8.2065Z",
22
+ fill: "white"
23
+ })));
24
+ };
25
+ export default {
26
+ success: /*#__PURE__*/React.createElement(Success, null),
27
+ running: /*#__PURE__*/React.createElement(Loading3QuartersOutlined, {
28
+ spin: true,
29
+ style: {
30
+ color: '#0c62ff'
31
+ }
32
+ })
33
+ };
@@ -1,2 +1,67 @@
1
- import TerminalViewerVirtualDom from './ReactVirtuoso';
2
- export default TerminalViewerVirtualDom;
1
+ import React from 'react';
2
+ import { IHighlightOptions } from '../Addon/HighlightAddon';
3
+ import type { SearcherRef } from '../Addon/WorkerLog/types';
4
+ import type { ICacheOptions } from '../Hooks/useCache';
5
+ import type { IRemoteOptions } from '../Hooks/useRemote';
6
+ import { ExtraOptions, LogAfterProps, TerminalRef, VirtualDomTerminal } from '../types';
7
+ import './index.less';
8
+ export interface TerminalViewerVirtualDomProps {
9
+ /**
10
+ * @description.zh-CN 是否自动拉伸填充容器宽高
11
+ * @default true
12
+ */
13
+ fit?: boolean;
14
+ /**
15
+ * @description.zh-CN 外层样式类名
16
+ */
17
+ className?: string;
18
+ /**
19
+ * @description.zh-CN 自定义空文本显示
20
+ */
21
+ empty?: React.ReactNode;
22
+ /**
23
+ *@description.zh-CN 是否开启自动滚动到底部
24
+ *@default true
25
+ */
26
+ autoScroll?: boolean;
27
+ /**
28
+ * @description.zh-CN 自动滚动到某一行,开启后自动滚动到底部失效
29
+ */
30
+ scrollToRow?: number;
31
+ /**
32
+ * @description.zh-CN 设置日志后置标签,仅在开启虚拟 DOM 生效
33
+ */
34
+ logAfter?: React.FunctionComponent<LogAfterProps> | React.ComponentClass<LogAfterProps>;
35
+ /**
36
+ * @description.zh-CN 用于渲染日志的默认数据,如 "echo 1\r\necho2"
37
+ * @default '''
38
+ */
39
+ defaultData?: string;
40
+ /**
41
+ * @description.zh-CN 远程搜索配置
42
+ *
43
+ */
44
+ remoteOptions?: IRemoteOptions;
45
+ /**
46
+ * @description.zh-CN 缓存配置,仅在配置远程加载后有效,如 `expires: 60 * 1000` 表示自动清理已过期一分钟的缓存
47
+ */
48
+ cacheOptions?: ICacheOptions;
49
+ /**
50
+ * @description.zh-CN 高亮选项
51
+ */
52
+ highlightOptions?: IHighlightOptions[];
53
+ /**
54
+ * @description.zh-CN 额外的功能选项 { showLineNumber 仅 虚拟 DOM 模式支持}
55
+ */
56
+ extraOptions?: ExtraOptions;
57
+ /**
58
+ * @description.zh-CN 插件加载成功后的回调
59
+ */
60
+ onAddonReady?: (instance?: VirtualDomTerminal, addon?: SearcherRef) => void;
61
+ /**
62
+ * @description.zh-CN 加载状态变更后的回调
63
+ */
64
+ onLoading?: (loading: boolean) => void;
65
+ }
66
+ declare const ReactVirtuoso: React.ForwardRefExoticComponent<TerminalViewerVirtualDomProps & React.RefAttributes<TerminalRef | undefined>>;
67
+ export default ReactVirtuoso;