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.
- package/README.md +181 -0
- package/dist/esm/Addon/EventEmiter.d.ts +18 -0
- package/dist/esm/Addon/EventEmiter.js +64 -0
- package/dist/esm/Addon/HighlightAddon.d.ts +26 -0
- package/dist/esm/Addon/HighlightAddon.js +188 -0
- package/dist/esm/Addon/SearchAddon.d.ts +140 -0
- package/dist/esm/Addon/SearchAddon.js +797 -0
- package/dist/esm/Addon/WorkerLog/GlobalContext.d.ts +10 -0
- package/dist/esm/Addon/WorkerLog/GlobalContext.js +37 -0
- package/dist/esm/Addon/WorkerLog/LimitMap.d.ts +14 -0
- package/dist/esm/Addon/WorkerLog/LimitMap.js +54 -0
- package/dist/esm/Addon/WorkerLog/LogWorker.d.ts +2 -0
- package/dist/esm/Addon/WorkerLog/LogWorker.js +13 -0
- package/dist/esm/Addon/WorkerLog/Logs.d.ts +21 -0
- package/dist/esm/Addon/WorkerLog/Logs.js +60 -0
- package/dist/esm/Addon/WorkerLog/Mark.d.ts +36 -0
- package/dist/esm/Addon/WorkerLog/Mark.js +155 -0
- package/dist/esm/Addon/WorkerLog/Searcher.d.ts +16 -0
- package/dist/esm/Addon/WorkerLog/Searcher.js +88 -0
- package/dist/esm/Addon/WorkerLog/WebWokerServer.d.ts +10 -0
- package/dist/esm/Addon/WorkerLog/WebWokerServer.js +57 -0
- package/dist/esm/Addon/WorkerLog/WebWorkerClient.d.ts +13 -0
- package/dist/esm/Addon/WorkerLog/WebWorkerClient.js +83 -0
- package/dist/esm/Addon/WorkerLog/log.worker.d.ts +1 -0
- package/dist/esm/Addon/WorkerLog/log.worker.js +63 -0
- package/dist/esm/Addon/WorkerLog/types.d.ts +18 -0
- package/dist/esm/Addon/WorkerLog/types.js +1 -0
- package/dist/esm/Addon/useAddon.d.ts +9 -0
- package/dist/esm/Addon/useAddon.js +33 -0
- package/dist/esm/Hooks/useBatchProcess.d.ts +2 -0
- package/dist/esm/Hooks/useBatchProcess.js +47 -0
- package/dist/esm/Hooks/useCache.d.ts +31 -0
- package/dist/esm/Hooks/useCache.js +206 -0
- package/dist/esm/Hooks/useDebounceInput.d.ts +3 -0
- package/dist/esm/Hooks/useDebounceInput.js +26 -0
- package/dist/esm/Hooks/useLocalStore.d.ts +2 -0
- package/dist/esm/Hooks/useLocalStore.js +9 -0
- package/dist/esm/Hooks/useRemote.d.ts +30 -0
- package/dist/esm/Hooks/useRemote.js +398 -0
- package/dist/esm/Hooks/useThrottle.d.ts +2 -0
- package/dist/esm/Hooks/useThrottle.js +13 -0
- package/dist/esm/Hooks/useWorkerLogs.d.ts +9 -0
- package/dist/esm/Hooks/useWorkerLogs.js +162 -0
- package/dist/esm/TerminalViewer/index.d.ts +185 -0
- package/dist/esm/TerminalViewer/index.js +292 -0
- package/dist/esm/TerminalViewer/index.less +17 -0
- package/dist/esm/TerminalViewerBody/index.d.ts +87 -0
- package/dist/esm/TerminalViewerBody/index.js +248 -0
- package/dist/esm/TerminalViewerBody/index.less +51 -0
- package/dist/esm/TerminalViewerHeader/index.d.ts +88 -0
- package/dist/esm/TerminalViewerHeader/index.js +129 -0
- package/dist/esm/TerminalViewerHeader/index.less +143 -0
- package/dist/esm/TerminalViewerToolBar/index.d.ts +46 -0
- package/dist/esm/TerminalViewerToolBar/index.js +28 -0
- package/dist/esm/TerminalViewerToolBar/index.less +32 -0
- package/dist/esm/TerminalViewerVirtualDom/index.d.ts +71 -0
- package/dist/esm/TerminalViewerVirtualDom/index.js +309 -0
- package/dist/esm/TerminalViewerVirtualDom/index.less +68 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/mock/index.d.ts +12 -0
- package/dist/esm/mock/index.js +98 -0
- package/dist/esm/types.d.ts +30 -0
- package/dist/esm/types.js +1 -0
- package/dist/worker/Addon/EventEmiter.d.ts +18 -0
- package/dist/worker/Addon/HighlightAddon.d.ts +26 -0
- package/dist/worker/Addon/SearchAddon.d.ts +140 -0
- package/dist/worker/Addon/WorkerLog/GlobalContext.d.ts +10 -0
- package/dist/worker/Addon/WorkerLog/LimitMap.d.ts +14 -0
- package/dist/worker/Addon/WorkerLog/LogWorker.d.ts +2 -0
- package/dist/worker/Addon/WorkerLog/Logs.d.ts +21 -0
- package/dist/worker/Addon/WorkerLog/Mark.d.ts +36 -0
- package/dist/worker/Addon/WorkerLog/Searcher.d.ts +16 -0
- package/dist/worker/Addon/WorkerLog/WebWokerServer.d.ts +10 -0
- package/dist/worker/Addon/WorkerLog/WebWorkerClient.d.ts +13 -0
- package/dist/worker/Addon/WorkerLog/log.worker.d.ts +1 -0
- package/dist/worker/Addon/WorkerLog/types.d.ts +18 -0
- package/dist/worker/Addon/useAddon.d.ts +9 -0
- package/dist/worker/Hooks/useBatchProcess.d.ts +2 -0
- package/dist/worker/Hooks/useCache.d.ts +31 -0
- package/dist/worker/Hooks/useDebounceInput.d.ts +3 -0
- package/dist/worker/Hooks/useLocalStore.d.ts +2 -0
- package/dist/worker/Hooks/useRemote.d.ts +30 -0
- package/dist/worker/Hooks/useRemote.test.d.ts +1 -0
- package/dist/worker/Hooks/useThrottle.d.ts +2 -0
- package/dist/worker/Hooks/useWorkerLogs.d.ts +9 -0
- package/dist/worker/TerminalViewer/index.d.ts +185 -0
- package/dist/worker/TerminalViewer/index.test.d.ts +1 -0
- package/dist/worker/TerminalViewerBody/index.d.ts +87 -0
- package/dist/worker/TerminalViewerBody/index.test.d.ts +1 -0
- package/dist/worker/TerminalViewerHeader/index.d.ts +88 -0
- package/dist/worker/TerminalViewerToolBar/index.d.ts +46 -0
- package/dist/worker/TerminalViewerVirtualDom/index.d.ts +71 -0
- package/dist/worker/index.d.ts +9 -0
- package/dist/worker/log.worker.js +2 -0
- package/dist/worker/log.worker.js.map +1 -0
- package/dist/worker/mock/index.d.ts +12 -0
- package/dist/worker/types.d.ts +30 -0
- package/package.json +97 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export function loadTest() {
|
|
2
|
+
var testData = '';
|
|
3
|
+
for (var i = 0; i < 100000; i += 1) {
|
|
4
|
+
testData += "\u5F53\u524D\u884C\uFF1A".concat(i + 1, "\r\n");
|
|
5
|
+
}
|
|
6
|
+
testData += 'done...\r';
|
|
7
|
+
return testData;
|
|
8
|
+
}
|
|
9
|
+
export function loadAdvancedTest() {
|
|
10
|
+
var testData = '';
|
|
11
|
+
testData += '[超链接] https://www.gitee.com\r\n';
|
|
12
|
+
testData += '[超链接] https://www.gitee.com/**/**\r\n';
|
|
13
|
+
for (var i = 0; i < 16; i += 1) {
|
|
14
|
+
testData += "\x1B[48;5;".concat(i, "m ").concat(i.toString().padEnd(2, ' ').padStart(3, ' '), " \x1B[0m");
|
|
15
|
+
}
|
|
16
|
+
for (var _i = 0; _i < 6; _i += 1) {
|
|
17
|
+
var startId = 16 + _i * 36;
|
|
18
|
+
var endId = 16 + (_i + 1) * 36 - 1;
|
|
19
|
+
testData += "".concat(startId.toString().padStart(3, ' '), "-").concat(endId.toString().padStart(3, ' '), " ");
|
|
20
|
+
for (var j = 0; j < 36; j += 1) {
|
|
21
|
+
var id = 16 + _i * 36 + j;
|
|
22
|
+
testData += "\x1B[48;5;".concat(id, "m").concat((id % 10).toString().padStart(2, ' '), "\x1B[0m");
|
|
23
|
+
}
|
|
24
|
+
testData += '\r\n';
|
|
25
|
+
}
|
|
26
|
+
return testData;
|
|
27
|
+
}
|
|
28
|
+
export function loadCustomHighLightTest() {
|
|
29
|
+
var random = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
30
|
+
var testData = '';
|
|
31
|
+
var log = function log() {
|
|
32
|
+
return '应当渲染正确的颜色'.repeat(random ? Math.floor(Math.random() * 50 + 1) : 30);
|
|
33
|
+
};
|
|
34
|
+
testData += "[".concat(new Date().toString(), "] [SUCCESS] ").concat(log(), "\r\n");
|
|
35
|
+
testData += "[".concat(new Date().toString(), "] [INFO] ").concat(log(), "\r\n");
|
|
36
|
+
testData += "[".concat(new Date().toString(), "] [info] ").concat(log(), "\r\n");
|
|
37
|
+
testData += "[".concat(new Date().toString(), "] [WARNING] ").concat(log(), "\r\n");
|
|
38
|
+
testData += "[".concat(new Date().toString(), "] [ERROR] ").concat(log(), "\r\n");
|
|
39
|
+
testData += "[".concat(new Date().toString(), "] \x1B[48;5;1m [SUCCESS] \u5E94\u5F53\u4F18\u5148\u6E32\u67D3\u989C\u8272\u7F16\u7801 \x1B[0m");
|
|
40
|
+
return testData;
|
|
41
|
+
}
|
|
42
|
+
export function fetchCustomHighLightTest() {
|
|
43
|
+
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
44
|
+
return new Promise(function (resolve) {
|
|
45
|
+
setTimeout(function () {
|
|
46
|
+
var result = loadCustomHighLightTest(true);
|
|
47
|
+
resolve({
|
|
48
|
+
next: start > 10000 ? null : function () {
|
|
49
|
+
return fetchCustomHighLightTest(start + 1000);
|
|
50
|
+
},
|
|
51
|
+
result: result
|
|
52
|
+
});
|
|
53
|
+
}, 300);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function remoteFetch() {
|
|
57
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
58
|
+
var start = Number(key);
|
|
59
|
+
return new Promise(function (resolve) {
|
|
60
|
+
setTimeout(function () {
|
|
61
|
+
var result = '';
|
|
62
|
+
for (var i = start; i < start + 1000; i += 1) {
|
|
63
|
+
result += "[".concat(new Date().toString(), "] \u5F53\u524D\u884C: ").concat(i, "\r\n");
|
|
64
|
+
}
|
|
65
|
+
resolve({
|
|
66
|
+
next: start > 10000 ? null : function () {
|
|
67
|
+
return remoteFetch(start + 1000);
|
|
68
|
+
},
|
|
69
|
+
result: result
|
|
70
|
+
});
|
|
71
|
+
}, 300);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function cacheFetch() {
|
|
75
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
76
|
+
var start = Number(key);
|
|
77
|
+
return new Promise(function (resolve) {
|
|
78
|
+
setTimeout(function () {
|
|
79
|
+
var result = '';
|
|
80
|
+
for (var i = start; i < start + 30000; i += 1) {
|
|
81
|
+
result += "[".concat(new Date().toString(), "] \u5F53\u524D\u884C: ").concat(i, "\r\n");
|
|
82
|
+
}
|
|
83
|
+
resolve({
|
|
84
|
+
key: start,
|
|
85
|
+
nextKey: start > 1000000 ? undefined : start + 30000,
|
|
86
|
+
next: start > 1000000 ? undefined : function () {
|
|
87
|
+
return cacheFetch(start + 30000);
|
|
88
|
+
},
|
|
89
|
+
result: result
|
|
90
|
+
});
|
|
91
|
+
}, 300);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export default {
|
|
95
|
+
loadTest: loadTest,
|
|
96
|
+
remoteFetch: remoteFetch,
|
|
97
|
+
cacheFetch: cacheFetch
|
|
98
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Terminal } from 'xterm';
|
|
2
|
+
import { FitAddon } from 'xterm-addon-fit';
|
|
3
|
+
import { WebLinksAddon } from 'xterm-addon-web-links';
|
|
4
|
+
import { CanvasAddon } from 'xterm-addon-canvas';
|
|
5
|
+
import { HighlightAddon } from './Addon/HighlightAddon';
|
|
6
|
+
import { SearchAddon } from './Addon/SearchAddon';
|
|
7
|
+
import type { SearcherRef } from './Addon/WorkerLog/types';
|
|
8
|
+
export interface ExtraOptions {
|
|
9
|
+
showLineNumber?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface VirtualDomTerminal {
|
|
12
|
+
scrollToTop: () => void;
|
|
13
|
+
scrollToBottom: () => void;
|
|
14
|
+
}
|
|
15
|
+
export interface TerminalRef {
|
|
16
|
+
el?: HTMLDivElement | null;
|
|
17
|
+
refresh: () => void;
|
|
18
|
+
addons?: {
|
|
19
|
+
search?: () => SearchAddon | SearcherRef | undefined;
|
|
20
|
+
fit?: () => FitAddon | undefined;
|
|
21
|
+
webLinks?: () => WebLinksAddon | undefined;
|
|
22
|
+
highlight?: () => HighlightAddon | undefined;
|
|
23
|
+
canvas?: () => CanvasAddon | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
terminal?: () => Terminal | VirtualDomTerminal | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface LogAfterProps {
|
|
28
|
+
index: number;
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IDisposable } from 'xterm';
|
|
2
|
+
export interface IEvent<T, U = void> {
|
|
3
|
+
(listener: (arg1: T, arg2: U) => any): IDisposable;
|
|
4
|
+
}
|
|
5
|
+
export interface IEventEmitter<T, U = void> {
|
|
6
|
+
event: IEvent<T, U>;
|
|
7
|
+
fire(arg1: T, arg2: U): void;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
10
|
+
declare class EventEmitter<T, U = void> implements IEventEmitter<T, U> {
|
|
11
|
+
private _listeners;
|
|
12
|
+
private _event?;
|
|
13
|
+
private _disposed;
|
|
14
|
+
get event(): IEvent<T, U>;
|
|
15
|
+
fire(arg1: T, arg2: U): void;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
18
|
+
export default EventEmitter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Terminal, ITerminalAddon } from 'xterm';
|
|
2
|
+
export interface IHighlightOptions {
|
|
3
|
+
keyword: string;
|
|
4
|
+
ignoreSensitive?: boolean;
|
|
5
|
+
decorations: {
|
|
6
|
+
matchForegroundColor?: string;
|
|
7
|
+
matchBackground?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 基于关键字的自定义高亮插件
|
|
12
|
+
*/
|
|
13
|
+
declare class HighlightAddon implements ITerminalAddon {
|
|
14
|
+
private _terminal;
|
|
15
|
+
private _cacheDecorations;
|
|
16
|
+
private _highlightTimeout;
|
|
17
|
+
activate(terminal: Terminal): void;
|
|
18
|
+
private _getLineProperty;
|
|
19
|
+
private _decoration;
|
|
20
|
+
private _clearDecoration;
|
|
21
|
+
private _updateHighlight;
|
|
22
|
+
highlight(options: IHighlightOptions[] | undefined): void;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
|
25
|
+
export { HighlightAddon };
|
|
26
|
+
export default HighlightAddon;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从 https://github.com/xtermjs/xterm.js/blob/master/addons/xterm-addon-search/src/SearchAddon.ts 复制以解决部分问题
|
|
3
|
+
*/
|
|
4
|
+
import { Terminal, ITerminalAddon } from 'xterm';
|
|
5
|
+
export interface ISearchOptions {
|
|
6
|
+
regex?: boolean;
|
|
7
|
+
wholeWord?: boolean;
|
|
8
|
+
caseSensitive?: boolean;
|
|
9
|
+
incremental?: boolean;
|
|
10
|
+
decorations?: ISearchDecorationOptions;
|
|
11
|
+
noScroll?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface ISearchDecorationOptions {
|
|
14
|
+
matchForegroundColor?: string;
|
|
15
|
+
matchBackground?: string;
|
|
16
|
+
matchBorder?: string;
|
|
17
|
+
matchOverviewRuler: string;
|
|
18
|
+
activeMatchBackground?: string;
|
|
19
|
+
activeMatchBorder?: string;
|
|
20
|
+
activeMatchColorOverviewRuler: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ISearchPosition {
|
|
23
|
+
startCol: number;
|
|
24
|
+
startRow: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ISearchResult {
|
|
27
|
+
term: string;
|
|
28
|
+
col: number;
|
|
29
|
+
row: number;
|
|
30
|
+
size: number;
|
|
31
|
+
}
|
|
32
|
+
export declare class SearchAddon implements ITerminalAddon {
|
|
33
|
+
private _terminal;
|
|
34
|
+
private _cachedSearchTerm;
|
|
35
|
+
private _selectedDecoration;
|
|
36
|
+
private _resultDecorations;
|
|
37
|
+
private _searchResults;
|
|
38
|
+
private _onDataDisposable;
|
|
39
|
+
private _onResizeDisposable;
|
|
40
|
+
private _lastSearchOptions;
|
|
41
|
+
private _highlightTimeout;
|
|
42
|
+
/**
|
|
43
|
+
* translateBufferLineToStringWithWrap is a fairly expensive call.
|
|
44
|
+
* We memoize the calls into an array that has a time based ttl.
|
|
45
|
+
* _linesCache is also invalidated when the terminal cursor moves.
|
|
46
|
+
*/
|
|
47
|
+
private _linesCache;
|
|
48
|
+
private _linesCacheTimeoutId;
|
|
49
|
+
private _cursorMoveListener;
|
|
50
|
+
private _resizeListener;
|
|
51
|
+
private _resultIndex;
|
|
52
|
+
private readonly _onDidChangeResults;
|
|
53
|
+
readonly onDidChangeResults: import("./EventEmiter").IEvent<{
|
|
54
|
+
resultIndex: number;
|
|
55
|
+
resultCount: number;
|
|
56
|
+
} | undefined, void>;
|
|
57
|
+
activate(terminal: Terminal): void;
|
|
58
|
+
private _updateMatches;
|
|
59
|
+
dispose(): void;
|
|
60
|
+
clearDecorations(retainCachedSearchTerm?: boolean): void;
|
|
61
|
+
clearActiveDecoration(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Find the next instance of the term, then scroll to and select it. If it
|
|
64
|
+
* doesn't exist, do nothing.
|
|
65
|
+
* @param term The search term.
|
|
66
|
+
* @param searchOptions Search options.
|
|
67
|
+
* @return Whether a result was found.
|
|
68
|
+
*/
|
|
69
|
+
findNext(term: string, searchOptions?: ISearchOptions): boolean;
|
|
70
|
+
private _highlightAllMatches;
|
|
71
|
+
private _find;
|
|
72
|
+
private _findNextAndSelect;
|
|
73
|
+
/**
|
|
74
|
+
* Find the previous instance of the term, then scroll to and select it. If it
|
|
75
|
+
* doesn't exist, do nothing.
|
|
76
|
+
* @param term The search term.
|
|
77
|
+
* @param searchOptions Search options.
|
|
78
|
+
* @return Whether a result was found.
|
|
79
|
+
*/
|
|
80
|
+
findPrevious(term: string, searchOptions?: ISearchOptions): boolean;
|
|
81
|
+
private _fireResults;
|
|
82
|
+
private _findPreviousAndSelect;
|
|
83
|
+
/**
|
|
84
|
+
* Sets up a line cache with a ttl
|
|
85
|
+
*/
|
|
86
|
+
private _initLinesCache;
|
|
87
|
+
private _destroyLinesCache;
|
|
88
|
+
/**
|
|
89
|
+
* A found substring is a whole word if it doesn't have an alphanumeric character directly adjacent to it.
|
|
90
|
+
* @param searchIndex starting indext of the potential whole word substring
|
|
91
|
+
* @param line entire string in which the potential whole word was found
|
|
92
|
+
* @param term the substring that starts at searchIndex
|
|
93
|
+
*/
|
|
94
|
+
private _isWholeWord;
|
|
95
|
+
/**
|
|
96
|
+
* Searches a line for a search term. Takes the provided terminal line and searches the text line, which may contain
|
|
97
|
+
* subsequent terminal lines if the text is wrapped. If the provided line number is part of a wrapped text line that
|
|
98
|
+
* started on an earlier line then it is skipped since it will be properly searched when the terminal line that the
|
|
99
|
+
* text starts on is searched.
|
|
100
|
+
* @param term The search term.
|
|
101
|
+
* @param position The position to start the search.
|
|
102
|
+
* @param searchOptions Search options.
|
|
103
|
+
* @param isReverseSearch Whether the search should start from the right side of the terminal and search to the left.
|
|
104
|
+
* @return The search result if it was found.
|
|
105
|
+
*/
|
|
106
|
+
protected _findInLine(term: string, searchPosition: ISearchPosition, searchOptions?: ISearchOptions, isReverseSearch?: boolean): ISearchResult | undefined;
|
|
107
|
+
private _stringLengthToBufferSize;
|
|
108
|
+
private _bufferColsToStringOffset;
|
|
109
|
+
/**
|
|
110
|
+
* Translates a buffer line to a string, including subsequent lines if they are wraps.
|
|
111
|
+
* Wide characters will count as two columns in the resulting string. This
|
|
112
|
+
* function is useful for getting the actual text underneath the raw selection
|
|
113
|
+
* position.
|
|
114
|
+
* @param line The line being translated.
|
|
115
|
+
* @param trimRight Whether to trim whitespace to the right.
|
|
116
|
+
*/
|
|
117
|
+
private _translateBufferLineToStringWithWrap;
|
|
118
|
+
/**
|
|
119
|
+
* Selects and scrolls to a result.
|
|
120
|
+
* @param result The result to select.
|
|
121
|
+
* @return Whether a result was selected.
|
|
122
|
+
*/
|
|
123
|
+
private _selectResult;
|
|
124
|
+
/**
|
|
125
|
+
* Applies styles to the decoration when it is rendered
|
|
126
|
+
* @param element the decoration's element
|
|
127
|
+
* @param backgroundColor the background color to apply
|
|
128
|
+
* @param borderColor the border color to apply
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
private _applyStyles;
|
|
132
|
+
/**
|
|
133
|
+
* Creates a decoration for the result and applies styles
|
|
134
|
+
* @param result the search result for which to create the decoration
|
|
135
|
+
* @param options the options for the decoration
|
|
136
|
+
* @returns the {@link IDecoration} or undefined if the marker has already been disposed of
|
|
137
|
+
*/
|
|
138
|
+
private _createResultDecoration;
|
|
139
|
+
}
|
|
140
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class LimitMap {
|
|
2
|
+
private map;
|
|
3
|
+
private queue;
|
|
4
|
+
private limit;
|
|
5
|
+
constructor(options?: {
|
|
6
|
+
limit: number;
|
|
7
|
+
});
|
|
8
|
+
get(key: string | number): any;
|
|
9
|
+
get size(): number;
|
|
10
|
+
set(key: string, value: any): Map<string | number, any>;
|
|
11
|
+
has(key: string | number): boolean;
|
|
12
|
+
delete(key: string | number): boolean;
|
|
13
|
+
}
|
|
14
|
+
export default LimitMap;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ISearchOptions } from '../SearchAddon';
|
|
2
|
+
export default class Logs {
|
|
3
|
+
private id;
|
|
4
|
+
private string;
|
|
5
|
+
private searcher;
|
|
6
|
+
private logDataMap;
|
|
7
|
+
constructor({ id, string }: {
|
|
8
|
+
id: string;
|
|
9
|
+
string: string;
|
|
10
|
+
});
|
|
11
|
+
convert(): string[];
|
|
12
|
+
getArrayData(): any;
|
|
13
|
+
mark(keyword: string, hlIndex?: number, options?: ISearchOptions | undefined): {
|
|
14
|
+
count: number;
|
|
15
|
+
map: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
[key: number]: string;
|
|
18
|
+
};
|
|
19
|
+
markedKey: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
declare class Mark {
|
|
2
|
+
private dom;
|
|
3
|
+
private options;
|
|
4
|
+
matchCount: number;
|
|
5
|
+
matchedIndex: number;
|
|
6
|
+
isMarked: boolean;
|
|
7
|
+
private hlIndex;
|
|
8
|
+
constructor(content: string, options?: {
|
|
9
|
+
className?: string;
|
|
10
|
+
markedClassName?: string;
|
|
11
|
+
style?: {
|
|
12
|
+
[key: string]: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
markedStyle?: {
|
|
15
|
+
[key: string]: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* 根据关键字标记文本
|
|
20
|
+
* @param {String} keyword - 搜索关键词
|
|
21
|
+
* @param {Number} options.matchedIndex - 已匹配的最大的索引
|
|
22
|
+
* @param {Number} options.hlIndex - 需要标记的索引
|
|
23
|
+
* @returns this
|
|
24
|
+
*/
|
|
25
|
+
mark(keyword: string, options?: {
|
|
26
|
+
matchedIndex: number;
|
|
27
|
+
hlIndex: number;
|
|
28
|
+
}): this;
|
|
29
|
+
escapeStr(str: string): string;
|
|
30
|
+
getStyle(isMarked: boolean): string;
|
|
31
|
+
getTextNodes(el: ChildNode): ChildNode[];
|
|
32
|
+
wrapRangeInTextNode(node: Text, start: number, end: number): Text;
|
|
33
|
+
toString(): string;
|
|
34
|
+
distory(): void;
|
|
35
|
+
}
|
|
36
|
+
export default Mark;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ISearchOptions } from '../SearchAddon';
|
|
2
|
+
export default class Searcher {
|
|
3
|
+
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
|
+
count: number;
|
|
10
|
+
map: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
[key: number]: string;
|
|
13
|
+
};
|
|
14
|
+
markedKey: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Callback = (context: WebWorkerServer, args: any) => void;
|
|
2
|
+
declare class WebWorkerServer {
|
|
3
|
+
private events;
|
|
4
|
+
private context;
|
|
5
|
+
constructor(context: Worker);
|
|
6
|
+
on(topic: string, callback: Callback): this;
|
|
7
|
+
exec(topic: string, data: any): this;
|
|
8
|
+
send(topic: string, payload?: {}): this;
|
|
9
|
+
}
|
|
10
|
+
export default WebWorkerServer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Callback = (args: any) => void;
|
|
2
|
+
declare class WebWorkerClient {
|
|
3
|
+
private events;
|
|
4
|
+
private worker;
|
|
5
|
+
constructor(worker: Worker);
|
|
6
|
+
once(topic: string, callback: Callback): this;
|
|
7
|
+
on(topic: string, callback: Callback): this;
|
|
8
|
+
off(topic: string, callback: Callback): this;
|
|
9
|
+
exec(topic: string, data: any): this;
|
|
10
|
+
send(topic: string, payload?: {}): this;
|
|
11
|
+
terminate(): this;
|
|
12
|
+
}
|
|
13
|
+
export default WebWorkerClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ISearchOptions } from '../SearchAddon';
|
|
2
|
+
export type SearchResultCallback = (result: SearcherResult) => void;
|
|
3
|
+
export type DidChangeResultsCallback = (e?: {
|
|
4
|
+
resultIndex: number;
|
|
5
|
+
resultCount: number;
|
|
6
|
+
}) => void;
|
|
7
|
+
export interface SearcherRef {
|
|
8
|
+
findPrevious: (keyword: string, options: ISearchOptions) => void;
|
|
9
|
+
findNext: (keyword: string, options: ISearchOptions) => void;
|
|
10
|
+
onDidChangeResults: (callback: DidChangeResultsCallback) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface SearcherResult {
|
|
13
|
+
count: number;
|
|
14
|
+
map: {
|
|
15
|
+
[key: string | number]: string;
|
|
16
|
+
};
|
|
17
|
+
markedKey: number | string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Terminal } from 'xterm';
|
|
2
|
+
import { FitAddon } from 'xterm-addon-fit';
|
|
3
|
+
import { CanvasAddon } from 'xterm-addon-canvas';
|
|
4
|
+
import { WebLinksAddon } from 'xterm-addon-web-links';
|
|
5
|
+
import { SearchAddon } from './SearchAddon';
|
|
6
|
+
import { HighlightAddon } from './HighlightAddon';
|
|
7
|
+
export type AddonType = FitAddon | WebLinksAddon | SearchAddon | HighlightAddon | CanvasAddon;
|
|
8
|
+
declare const useAddon: (terminal: Terminal | undefined, Addon: new () => AddonType, loadable: boolean, callback?: ((term: Terminal, instance: AddonType) => void) | undefined) => AddonType | undefined;
|
|
9
|
+
export default useAddon;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ICacheOptions {
|
|
2
|
+
expires?: number;
|
|
3
|
+
}
|
|
4
|
+
export interface CacheItemValue {
|
|
5
|
+
nextKey?: string | number;
|
|
6
|
+
result: string;
|
|
7
|
+
complete: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type CacheItem = {
|
|
10
|
+
[key: string | number]: CacheItemValue | number | undefined;
|
|
11
|
+
__updateTime__?: number;
|
|
12
|
+
__expiresTime__?: number;
|
|
13
|
+
};
|
|
14
|
+
declare const useCache: (itemKey: number | string | undefined, valueKey: number | string | undefined, cacheOptions?: ICacheOptions) => {
|
|
15
|
+
store: LocalForage;
|
|
16
|
+
setCache: (key: string | number, value: CacheItemValue) => Promise<CacheItem | null>;
|
|
17
|
+
getCache: () => Promise<{
|
|
18
|
+
key: undefined;
|
|
19
|
+
complete: boolean;
|
|
20
|
+
next: undefined;
|
|
21
|
+
result: string;
|
|
22
|
+
} | {
|
|
23
|
+
key: string | number;
|
|
24
|
+
complete: boolean;
|
|
25
|
+
result: string;
|
|
26
|
+
next: undefined;
|
|
27
|
+
}>;
|
|
28
|
+
clearCache: () => Promise<void | null>;
|
|
29
|
+
destroyCache: () => Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
export default useCache;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ICacheOptions } from './useCache';
|
|
3
|
+
export interface IRemoteOptions {
|
|
4
|
+
fetch?: (cacheValueKey?: string | number) => Promise<FetchResult>;
|
|
5
|
+
cacheKey?: string | number;
|
|
6
|
+
cacheValueKey?: string | number;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
retry?: number;
|
|
9
|
+
enableBatch?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type UseRemoteHooks = (defaultData: string, callback?: (string: string) => void, options?: IRemoteOptions | undefined, cacheOptions?: ICacheOptions) => {
|
|
12
|
+
data: string;
|
|
13
|
+
refresh: () => void;
|
|
14
|
+
cacheStore: LocalForage;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
};
|
|
17
|
+
export interface FetchResult {
|
|
18
|
+
result: string;
|
|
19
|
+
next: (() => Promise<FetchResult>) | undefined;
|
|
20
|
+
key?: string | number;
|
|
21
|
+
nextKey?: string | number;
|
|
22
|
+
}
|
|
23
|
+
export declare const useSequenceFetch: (fetch: ((cacheValueKey?: string | number) => Promise<FetchResult>) | undefined, callback: (data: string) => Promise<void>, options: Pick<IRemoteOptions, 'timeout' | 'retry' | 'cacheKey' | 'cacheValueKey'>, cacheOptions?: ICacheOptions) => {
|
|
24
|
+
loading: boolean;
|
|
25
|
+
setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
26
|
+
refresh: () => Promise<void>;
|
|
27
|
+
cacheStore: LocalForage;
|
|
28
|
+
};
|
|
29
|
+
declare const useRemote: UseRemoteHooks;
|
|
30
|
+
export default useRemote;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SearchResultCallback, SearcherRef, SearcherResult } from '../Addon/WorkerLog/types';
|
|
3
|
+
export declare const useWorkerLogs: (string: string, changeCallback?: SearchResultCallback) => {
|
|
4
|
+
logs: string[];
|
|
5
|
+
working: boolean;
|
|
6
|
+
searcherRef: import("react").MutableRefObject<SearcherRef | undefined>;
|
|
7
|
+
searcherResult: SearcherResult;
|
|
8
|
+
};
|
|
9
|
+
export default useWorkerLogs;
|