react-terminal-viewer-cicd 3.0.0-beta.44 → 3.0.0-beta.45

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.
@@ -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.44" || '0.0.0';
4
+ var version = "3.0.0-beta.45" || '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 +1 @@
1
- {"version":3,"file":"PipelineLogViewer.d.ts","sourceRoot":"","sources":["../../../src/PipelineLogViewer/PipelineLogViewer.tsx"],"names":[],"mappings":"AAoBA,OAAO,KASN,MAAM,OAAO,CAAC;AAiBf,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAGV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAwEjB,QAAA,MAAM,iBAAiB,qGAkyCtB,CAAC;AAIF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"PipelineLogViewer.d.ts","sourceRoot":"","sources":["../../../src/PipelineLogViewer/PipelineLogViewer.tsx"],"names":[],"mappings":"AAoBA,OAAO,KASN,MAAM,OAAO,CAAC;AAiBf,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAGV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAwEjB,QAAA,MAAM,iBAAiB,qGAkzCtB,CAAC;AAIF,eAAe,iBAAiB,CAAC"}
@@ -580,26 +580,39 @@ var PipelineLogViewer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
580
580
  }
581
581
  var anchorRowNext = pendingScrollAfterNextRef.current;
582
582
  if (anchorRowNext !== null) {
583
+ var _scrollerDomRef$curre3, _scrollerDomRef$curre4;
583
584
  var _lenBefore = displayLogsLenBeforeLoadNextRef.current;
584
585
  var _sameLength = _lenBefore !== null && _lenBefore === displayLogs.length && displayLogs.length > 0;
585
586
  var headRemoved = headRemovedFromNextRef.current;
586
587
  pendingScrollAfterNextRef.current = null;
587
588
  displayLogsLenBeforeLoadNextRef.current = null;
588
- ignoreBoundaryFetchRef.current = Date.now() + IGNORE_BOUNDARY_FETCH_MS_AFTER_SCROLL;
589
- var comp = applyBoundaryScrollCompensation(v, anchorRowNext, displayLogs, {
589
+
590
+ // 极大缩短屏蔽窗口(原本500ms):仅用 50ms 屏蔽当前帧由于 scrollTop 重置引起的乱序 rangeChanged。
591
+ // 不再长时间屏蔽,使得用户在快速下滚时 rangeChanged 依然灵敏,消除“触底发呆/卡顿”感。
592
+ ignoreBoundaryFetchRef.current = Date.now() + 50;
593
+
594
+ // 因为不再有漫长的屏蔽期,无需跟进定时器补偿,直接清理
595
+ if (boundaryIgnoreFollowUpTimeoutRef.current) {
596
+ clearTimeout(boundaryIgnoreFollowUpTimeoutRef.current);
597
+ boundaryIgnoreFollowUpTimeoutRef.current = null;
598
+ }
599
+
600
+ // 读取当前实时 scrollTop,而非请求前快照的 scrollTopBeforeLoadNextRef,
601
+ // 避免用户在 API 请求期间继续滚动导致补偿基准过时(跳屏)。
602
+ var realTimeScrollTop = (_scrollerDomRef$curre3 = (_scrollerDomRef$curre4 = scrollerDomRef.current) === null || _scrollerDomRef$curre4 === void 0 ? void 0 : _scrollerDomRef$curre4.scrollTop) !== null && _scrollerDomRef$curre3 !== void 0 ? _scrollerDomRef$curre3 : scrollTopBeforeLoadNextRef.current;
603
+ applyBoundaryScrollCompensation(v, anchorRowNext, displayLogs, {
590
604
  sameLength: _sameLength && headRemoved > 0,
591
605
  sameLengthPixelDeltaCount: headRemoved,
592
606
  scrollTopBefore: scrollTopBeforeLoadNextRef.current,
607
+ // 保留接口签名所需,但已被 currentScrollTop 覆盖作用
593
608
  defaultItemHeight: DEFAULT_VIRTUOSO_ITEM_HEIGHT,
594
- mode: 'appendHeadSlice'
609
+ mode: 'appendHeadSlice',
610
+ currentScrollTop: realTimeScrollTop
595
611
  });
596
- if (comp.kind === 'anchorMissing') {
597
- v.scrollToIndex({
598
- index: 'LAST',
599
- align: 'end',
600
- behavior: 'auto'
601
- });
602
- }
612
+
613
+ // 注意:这里不再添加 scrollIntoView 精修对齐。
614
+ // 实测在用户连续滚动滑轮/触摸板时,scrollIntoView 会强行接管视口,打断浏览器的滚动动量(momentum),
615
+ // 导致体感上每翻 5000 行截断时就会“硬卡一下”。仅做单纯的 scrollTop 像素增减,能保持滚动的平滑。
603
616
  }
604
617
  }, [displayLogs]);
605
618
 
@@ -9,7 +9,7 @@ export declare const DEFAULT_VIRTUOSO_ITEM_HEIGHT = 20;
9
9
  * 过小(如 10)时,必须把「缓冲区内第一屏」滚到几乎贴顶才触发,此时锚点往往是 bufferStart(如 7550),
10
10
  * 而不是用户刚看到的行(如 7571 在顶时 startIndex 可能已是 21,却满足不了 <=10)。
11
11
  */
12
- export declare const BOUNDARY_PREFETCH_INDEX_MARGIN = 200;
12
+ export declare const BOUNDARY_PREFETCH_INDEX_MARGIN = 400;
13
13
  /**
14
14
  * 首屏 init / 新日志源首包:屏蔽 rangeChanged 边界预取时长 (ms)。
15
15
  * 略长于普通窗口,避免弹窗首帧、scrollToIndex(LAST) 前误判触顶触发 loadPrev。
@@ -17,7 +17,7 @@ export var DEFAULT_VIRTUOSO_ITEM_HEIGHT = 20;
17
17
  * 过小(如 10)时,必须把「缓冲区内第一屏」滚到几乎贴顶才触发,此时锚点往往是 bufferStart(如 7550),
18
18
  * 而不是用户刚看到的行(如 7571 在顶时 startIndex 可能已是 21,却满足不了 <=10)。
19
19
  */
20
- export var BOUNDARY_PREFETCH_INDEX_MARGIN = 200;
20
+ export var BOUNDARY_PREFETCH_INDEX_MARGIN = 400;
21
21
 
22
22
  /**
23
23
  * 首屏 init / 新日志源首包:屏蔽 rangeChanged 边界预取时长 (ms)。
@@ -1 +1 @@
1
- {"version":3,"file":"useStickyHeader.d.ts","sourceRoot":"","sources":["../../../../src/PipelineLogViewer/hooks/useStickyHeader.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,UAAU,sBAAsB;IAC9B,WAAW;IACX,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,UAAU,qBAAqB;IAC7B,0CAA0C;IAC1C,WAAW,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACzE;AAqCD;;GAEG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,qBAAqB,CA0B/E;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"useStickyHeader.d.ts","sourceRoot":"","sources":["../../../../src/PipelineLogViewer/hooks/useStickyHeader.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,UAAU,sBAAsB;IAC9B,WAAW;IACX,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,UAAU,qBAAqB;IAC7B,0CAA0C;IAC1C,WAAW,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACzE;AA6CD;;GAEG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,qBAAqB,CAsC/E;AAED,eAAe,eAAe,CAAC"}
@@ -15,6 +15,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  // ============================================================================
16
16
 
17
17
  import { useCallback, useEffect, useState } from 'react';
18
+ /** 提前探测行数:让吸顶分组在边界前更早感知切换趋势 */
19
+ var STICKY_LEAD_ROWS = 2;
20
+ /**
21
+ * 新分组头仍在视口可见区时,暂不渲染吸顶,避免出现「吸顶头 + 列表头」双头重影。
22
+ * 该窗口用绝对行号近似:Top 仍落在 group.start 附近时,优先显示列表内真实头。
23
+ */
24
+ var STICKY_SUPPRESS_ROWS_NEAR_GROUP_START = 1;
25
+
18
26
  /** 与 useDisplayLogs 折叠区间算法一致的有效上界(用于判断行是否落在该组) */
19
27
  function effectiveGroupEnd(group, gi, groups, bufferEnd) {
20
28
  var start = group.start,
@@ -68,7 +76,19 @@ function useStickyHeader(options) {
68
76
  setStickyGroup(null);
69
77
  return;
70
78
  }
71
- setStickyGroup(findStickyGroup(groups, absoluteTopRow, bufferEnd));
79
+ var stickyProbeRow = Math.max(0, absoluteTopRow + STICKY_LEAD_ROWS);
80
+ var nextStickyGroup = findStickyGroup(groups, stickyProbeRow, bufferEnd);
81
+ if (!nextStickyGroup) {
82
+ setStickyGroup(null);
83
+ return;
84
+ }
85
+ // 边界抑制:提前命中新分组时,其真实 GroupHeader 常仍在视口内,
86
+ // 这时渲染吸顶会出现双头。让列表内头部先过顶,再接管吸顶展示。
87
+ if (absoluteTopRow <= nextStickyGroup.start + STICKY_SUPPRESS_ROWS_NEAR_GROUP_START) {
88
+ setStickyGroup(null);
89
+ return;
90
+ }
91
+ setStickyGroup(nextStickyGroup);
72
92
  }, [groups]);
73
93
  return {
74
94
  stickyGroup: stickyGroup,
@@ -8,7 +8,9 @@ export type BoundaryScrollResult = {
8
8
  };
9
9
  /**
10
10
  * 滑动窗口 totalCount 不变时,Virtuoso 不会自动补偿 scrollTop。
11
- * 用像素粗调 + scrollIntoView 对齐到锚点行(与 loadPrev/loadNext 对称)。
11
+ * - prepend 模式:像素粗调 + scrollIntoView 对齐到锚点行。
12
+ * - appendHeadSlice 模式:仅用当前实时 scrollTop 减去截断行的像素偏移量。
13
+ * 不做锚点行定位,避免用户在 API 请求期间继续滚动时被强行拉回旧位置(跳屏)。
12
14
  */
13
15
  export declare function applyBoundaryScrollCompensation(v: VirtuosoHandle, anchorRow: number, rowsWithAbsolute: Array<{
14
16
  absoluteRow: number;
@@ -19,4 +21,9 @@ export declare function applyBoundaryScrollCompensation(v: VirtuosoHandle, ancho
19
21
  scrollTopBefore: number;
20
22
  defaultItemHeight: number;
21
23
  mode: BoundaryScrollMode;
24
+ /**
25
+ * appendHeadSlice 专用:当前实时 scrollTop(从 scroller DOM 读取)。
26
+ * 优先于 scrollTopBefore 使用,避免请求期间用户继续滚动导致补偿基准过时。
27
+ */
28
+ currentScrollTop?: number;
22
29
  }): BoundaryScrollResult;
@@ -1 +1 @@
1
- {"version":3,"file":"virtuosoBoundaryScroll.d.ts","sourceRoot":"","sources":["../../../../src/PipelineLogViewer/utils/virtuosoBoundaryScroll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,6DAA6D;AAC7D,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAE/D,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,CAAC,EAAE,cAAc,EACjB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,KAAK,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,EAC5D,OAAO,EAAE;IACP,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,yBAAyB,EAAE,MAAM,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,kBAAkB,CAAC;CAC1B,GACA,oBAAoB,CAgCtB"}
1
+ {"version":3,"file":"virtuosoBoundaryScroll.d.ts","sourceRoot":"","sources":["../../../../src/PipelineLogViewer/utils/virtuosoBoundaryScroll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,6DAA6D;AAC7D,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAE/D,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAE9E;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,CAAC,EAAE,cAAc,EACjB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,KAAK,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,EAC5D,OAAO,EAAE;IACP,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,yBAAyB,EAAE,MAAM,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,kBAAkB,CAAC;IACzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GACA,oBAAoB,CAyDtB"}
@@ -2,9 +2,51 @@
2
2
 
3
3
  /**
4
4
  * 滑动窗口 totalCount 不变时,Virtuoso 不会自动补偿 scrollTop。
5
- * 用像素粗调 + scrollIntoView 对齐到锚点行(与 loadPrev/loadNext 对称)。
5
+ * - prepend 模式:像素粗调 + scrollIntoView 对齐到锚点行。
6
+ * - appendHeadSlice 模式:仅用当前实时 scrollTop 减去截断行的像素偏移量。
7
+ * 不做锚点行定位,避免用户在 API 请求期间继续滚动时被强行拉回旧位置(跳屏)。
6
8
  */
7
9
  export function applyBoundaryScrollCompensation(v, anchorRow, rowsWithAbsolute, options) {
10
+ var sameLength = options.sameLength,
11
+ sameLengthPixelDeltaCount = options.sameLengthPixelDeltaCount,
12
+ scrollTopBefore = options.scrollTopBefore,
13
+ defaultItemHeight = options.defaultItemHeight,
14
+ mode = options.mode;
15
+
16
+ // -----------------------------------------------------------------------
17
+ // appendHeadSlice(loadNext 满载截断头部):
18
+ // 仅做像素偏移补偿,不做锚点行定位。
19
+ //
20
+ // 原理:head 截断 N 行后,所有 item 的 index 减小了 N,
21
+ // 视觉上内容整体上移了 N * itemHeight 像素。
22
+ // 要保持用户看到的内容不变,scrollTop 需减去同样的像素量。
23
+ //
24
+ // 使用 currentScrollTop(实时值)而非 scrollTopBefore(请求前快照),
25
+ // 解决用户在 API 请求期间继续滚动导致的跳屏问题。
26
+ // -----------------------------------------------------------------------
27
+ if (mode === 'appendHeadSlice') {
28
+ if (sameLength && sameLengthPixelDeltaCount > 0) {
29
+ var _options$currentScrol;
30
+ var baseScrollTop = (_options$currentScrol = options.currentScrollTop) !== null && _options$currentScrol !== void 0 ? _options$currentScrol : scrollTopBefore;
31
+ var delta = -sameLengthPixelDeltaCount * defaultItemHeight;
32
+ var top = Math.max(0, baseScrollTop + delta);
33
+ v.scrollTo({
34
+ top: top,
35
+ behavior: 'auto'
36
+ });
37
+ }
38
+ // 不管有没有像素补偿,都不再用锚点行做 scrollIntoView,
39
+ // 避免强行拉回旧位置。
40
+ return {
41
+ kind: 'ok'
42
+ };
43
+ }
44
+
45
+ // -----------------------------------------------------------------------
46
+ // prepend(loadPrev 满载截断尾部):
47
+ // 像素粗调 + scrollIntoView 锚点行精确对齐。
48
+ // prepend 场景下用户通常在最顶部等待加载,scrollTopBefore 不会过时。
49
+ // -----------------------------------------------------------------------
8
50
  var newIndex = rowsWithAbsolute.findIndex(function (l) {
9
51
  return l && l.absoluteRow === anchorRow;
10
52
  });
@@ -13,22 +55,17 @@ export function applyBoundaryScrollCompensation(v, anchorRow, rowsWithAbsolute,
13
55
  kind: 'anchorMissing'
14
56
  };
15
57
  }
16
- var sameLength = options.sameLength,
17
- sameLengthPixelDeltaCount = options.sameLengthPixelDeltaCount,
18
- scrollTopBefore = options.scrollTopBefore,
19
- defaultItemHeight = options.defaultItemHeight,
20
- mode = options.mode;
21
58
  if (sameLength && sameLengthPixelDeltaCount > 0) {
22
- var delta = mode === 'prepend' ? sameLengthPixelDeltaCount * defaultItemHeight : -sameLengthPixelDeltaCount * defaultItemHeight;
23
- var top = Math.max(0, scrollTopBefore + delta);
59
+ var _delta = sameLengthPixelDeltaCount * defaultItemHeight;
60
+ var _top = Math.max(0, scrollTopBefore + _delta);
24
61
  v.scrollTo({
25
- top: top,
62
+ top: _top,
26
63
  behavior: 'auto'
27
64
  });
28
65
  requestAnimationFrame(function () {
29
66
  v.scrollIntoView({
30
67
  index: newIndex,
31
- align: mode === 'prepend' ? 'start' : 'end',
68
+ align: 'start',
32
69
  behavior: 'auto'
33
70
  });
34
71
  });
@@ -38,7 +75,7 @@ export function applyBoundaryScrollCompensation(v, anchorRow, rowsWithAbsolute,
38
75
  }
39
76
  v.scrollToIndex({
40
77
  index: newIndex,
41
- align: mode === 'prepend' ? 'start' : 'end',
78
+ align: 'start',
42
79
  behavior: 'auto'
43
80
  });
44
81
  return {
@@ -9,7 +9,7 @@ export declare const DEFAULT_VIRTUOSO_ITEM_HEIGHT = 20;
9
9
  * 过小(如 10)时,必须把「缓冲区内第一屏」滚到几乎贴顶才触发,此时锚点往往是 bufferStart(如 7550),
10
10
  * 而不是用户刚看到的行(如 7571 在顶时 startIndex 可能已是 21,却满足不了 <=10)。
11
11
  */
12
- export declare const BOUNDARY_PREFETCH_INDEX_MARGIN = 200;
12
+ export declare const BOUNDARY_PREFETCH_INDEX_MARGIN = 400;
13
13
  /**
14
14
  * 首屏 init / 新日志源首包:屏蔽 rangeChanged 边界预取时长 (ms)。
15
15
  * 略长于普通窗口,避免弹窗首帧、scrollToIndex(LAST) 前误判触顶触发 loadPrev。
@@ -8,7 +8,9 @@ export type BoundaryScrollResult = {
8
8
  };
9
9
  /**
10
10
  * 滑动窗口 totalCount 不变时,Virtuoso 不会自动补偿 scrollTop。
11
- * 用像素粗调 + scrollIntoView 对齐到锚点行(与 loadPrev/loadNext 对称)。
11
+ * - prepend 模式:像素粗调 + scrollIntoView 对齐到锚点行。
12
+ * - appendHeadSlice 模式:仅用当前实时 scrollTop 减去截断行的像素偏移量。
13
+ * 不做锚点行定位,避免用户在 API 请求期间继续滚动时被强行拉回旧位置(跳屏)。
12
14
  */
13
15
  export declare function applyBoundaryScrollCompensation(v: VirtuosoHandle, anchorRow: number, rowsWithAbsolute: Array<{
14
16
  absoluteRow: number;
@@ -19,4 +21,9 @@ export declare function applyBoundaryScrollCompensation(v: VirtuosoHandle, ancho
19
21
  scrollTopBefore: number;
20
22
  defaultItemHeight: number;
21
23
  mode: BoundaryScrollMode;
24
+ /**
25
+ * appendHeadSlice 专用:当前实时 scrollTop(从 scroller DOM 读取)。
26
+ * 优先于 scrollTopBefore 使用,避免请求期间用户继续滚动导致补偿基准过时。
27
+ */
28
+ currentScrollTop?: number;
22
29
  }): BoundaryScrollResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-terminal-viewer-cicd",
3
- "version": "3.0.0-beta.44",
3
+ "version": "3.0.0-beta.45",
4
4
  "author": "https://gitee.com/gitee-frontend",
5
5
  "license": "MIT",
6
6
  "keywords": [