@echothink-ui/developer 0.1.0
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 +5 -0
- package/dist/components/APIExplorer.d.ts +2 -0
- package/dist/components/BranchSelector.d.ts +2 -0
- package/dist/components/CodeBlock.d.ts +2 -0
- package/dist/components/CodeEditor.d.ts +2 -0
- package/dist/components/CommitList.d.ts +2 -0
- package/dist/components/DiffTable.d.ts +2 -0
- package/dist/components/DiffViewer.d.ts +2 -0
- package/dist/components/EventPayloadViewer.d.ts +2 -0
- package/dist/components/GitRepositoryPanel.d.ts +2 -0
- package/dist/components/JSONViewer.d.ts +2 -0
- package/dist/components/LogConsole.d.ts +2 -0
- package/dist/components/PullRequestPanel.d.ts +2 -0
- package/dist/components/RequestResponseViewer.d.ts +2 -0
- package/dist/components/SchemaViewer.d.ts +2 -0
- package/dist/components/TerminalPanel.d.ts +2 -0
- package/dist/components/TraceTimeline.d.ts +2 -0
- package/dist/components/WebhookEventViewer.d.ts +2 -0
- package/dist/components/YAMLViewer.d.ts +2 -0
- package/dist/components/devUtils.d.ts +10 -0
- package/dist/components/types.d.ts +196 -0
- package/dist/index.cjs +2627 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +3651 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +2572 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
- package/src/components/APIExplorer.tsx +205 -0
- package/src/components/BranchSelector.tsx +54 -0
- package/src/components/CodeBlock.tsx +127 -0
- package/src/components/CodeEditor.tsx +95 -0
- package/src/components/CommitList.tsx +100 -0
- package/src/components/DiffTable.tsx +288 -0
- package/src/components/DiffViewer.tsx +145 -0
- package/src/components/EventPayloadViewer.tsx +91 -0
- package/src/components/GitRepositoryPanel.tsx +73 -0
- package/src/components/JSONViewer.tsx +189 -0
- package/src/components/LogConsole.tsx +160 -0
- package/src/components/PullRequestPanel.test.tsx +52 -0
- package/src/components/PullRequestPanel.tsx +215 -0
- package/src/components/RequestResponseViewer.test.tsx +45 -0
- package/src/components/RequestResponseViewer.tsx +169 -0
- package/src/components/SchemaViewer.tsx +157 -0
- package/src/components/TerminalPanel.test.tsx +33 -0
- package/src/components/TerminalPanel.tsx +134 -0
- package/src/components/TraceTimeline.test.tsx +63 -0
- package/src/components/TraceTimeline.tsx +207 -0
- package/src/components/WebhookEventViewer.test.tsx +57 -0
- package/src/components/WebhookEventViewer.tsx +184 -0
- package/src/components/YAMLViewer.tsx +207 -0
- package/src/components/devUtils.ts +81 -0
- package/src/components/types.ts +230 -0
- package/src/index.tsx +72 -0
- package/src/styles.css +4296 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface DiffLine {
|
|
2
|
+
type: "equal" | "add" | "remove";
|
|
3
|
+
beforeLine?: number;
|
|
4
|
+
afterLine?: number;
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function splitLines(value: string) {
|
|
9
|
+
return value.length ? value.replace(/\r\n/g, "\n").split("\n") : [""];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function buildLineDiff(before: string, after: string): DiffLine[] {
|
|
13
|
+
const a = splitDiffLines(before);
|
|
14
|
+
const b = splitDiffLines(after);
|
|
15
|
+
const table = Array.from({ length: a.length + 1 }, () => Array<number>(b.length + 1).fill(0));
|
|
16
|
+
|
|
17
|
+
for (let i = a.length - 1; i >= 0; i -= 1) {
|
|
18
|
+
for (let j = b.length - 1; j >= 0; j -= 1) {
|
|
19
|
+
table[i][j] =
|
|
20
|
+
a[i] === b[j]
|
|
21
|
+
? (table[i + 1]?.[j + 1] ?? 0) + 1
|
|
22
|
+
: Math.max(table[i + 1]?.[j] ?? 0, table[i]?.[j + 1] ?? 0);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const lines: DiffLine[] = [];
|
|
27
|
+
let i = 0;
|
|
28
|
+
let j = 0;
|
|
29
|
+
let beforeLine = 1;
|
|
30
|
+
let afterLine = 1;
|
|
31
|
+
|
|
32
|
+
while (i < a.length && j < b.length) {
|
|
33
|
+
if (a[i] === b[j]) {
|
|
34
|
+
lines.push({ type: "equal", beforeLine, afterLine, text: a[i] ?? "" });
|
|
35
|
+
i += 1;
|
|
36
|
+
j += 1;
|
|
37
|
+
beforeLine += 1;
|
|
38
|
+
afterLine += 1;
|
|
39
|
+
} else if ((table[i + 1]?.[j] ?? 0) >= (table[i]?.[j + 1] ?? 0)) {
|
|
40
|
+
lines.push({ type: "remove", beforeLine, text: a[i] ?? "" });
|
|
41
|
+
i += 1;
|
|
42
|
+
beforeLine += 1;
|
|
43
|
+
} else {
|
|
44
|
+
lines.push({ type: "add", afterLine, text: b[j] ?? "" });
|
|
45
|
+
j += 1;
|
|
46
|
+
afterLine += 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
while (i < a.length) {
|
|
51
|
+
lines.push({ type: "remove", beforeLine, text: a[i] ?? "" });
|
|
52
|
+
i += 1;
|
|
53
|
+
beforeLine += 1;
|
|
54
|
+
}
|
|
55
|
+
while (j < b.length) {
|
|
56
|
+
lines.push({ type: "add", afterLine, text: b[j] ?? "" });
|
|
57
|
+
j += 1;
|
|
58
|
+
afterLine += 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return lines;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function splitDiffLines(value: string) {
|
|
65
|
+
const lines = value.length ? value.replace(/\r\n/g, "\n").split("\n") : [];
|
|
66
|
+
return lines.length > 1 && lines[lines.length - 1] === "" ? lines.slice(0, -1) : lines;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function formatUnknown(value: unknown) {
|
|
70
|
+
if (typeof value === "string") return value;
|
|
71
|
+
if (value == null) return "";
|
|
72
|
+
try {
|
|
73
|
+
return JSON.stringify(value, null, 2);
|
|
74
|
+
} catch {
|
|
75
|
+
return String(value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function compactSha(sha: string) {
|
|
80
|
+
return sha.length > 10 ? sha.slice(0, 10) : sha;
|
|
81
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { EthOperationalStatus, SelectProps } from "@echothink-ui/core";
|
|
3
|
+
|
|
4
|
+
export interface CodeBlockProps extends React.HTMLAttributes<HTMLElement> {
|
|
5
|
+
code: string;
|
|
6
|
+
language?: string;
|
|
7
|
+
showLineNumbers?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CodeEditorProps extends Omit<
|
|
11
|
+
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
12
|
+
"onChange" | "value" | "readOnly"
|
|
13
|
+
> {
|
|
14
|
+
value: string;
|
|
15
|
+
onChange?: (value: string) => void;
|
|
16
|
+
language?: string;
|
|
17
|
+
readonly?: boolean;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
schemaRef?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DiffViewerProps extends React.HTMLAttributes<HTMLElement> {
|
|
23
|
+
before: string;
|
|
24
|
+
after: string;
|
|
25
|
+
mode?: "inline" | "side-by-side";
|
|
26
|
+
language?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type DiffTableChangeType =
|
|
30
|
+
| "added"
|
|
31
|
+
| "modified"
|
|
32
|
+
| "removed"
|
|
33
|
+
| "renamed"
|
|
34
|
+
| "unchanged"
|
|
35
|
+
| "conflict";
|
|
36
|
+
|
|
37
|
+
export interface DiffTableRow extends Record<string, unknown> {
|
|
38
|
+
id: string;
|
|
39
|
+
file?: string;
|
|
40
|
+
path?: string;
|
|
41
|
+
beforePath?: string;
|
|
42
|
+
afterPath?: string;
|
|
43
|
+
changeType?: DiffTableChangeType;
|
|
44
|
+
added?: number;
|
|
45
|
+
additions?: number;
|
|
46
|
+
removed?: number;
|
|
47
|
+
deletions?: number;
|
|
48
|
+
hunks?: number;
|
|
49
|
+
summary?: React.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface DiffTableProps extends Omit<
|
|
53
|
+
React.HTMLAttributes<HTMLElement>,
|
|
54
|
+
"children" | "title"
|
|
55
|
+
> {
|
|
56
|
+
rows: DiffTableRow[];
|
|
57
|
+
mode?: "inline" | "side-by-side";
|
|
58
|
+
title?: React.ReactNode;
|
|
59
|
+
subtitle?: React.ReactNode;
|
|
60
|
+
showSummary?: boolean;
|
|
61
|
+
emptyState?: React.ReactNode;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface JSONViewerProps extends React.HTMLAttributes<HTMLElement> {
|
|
65
|
+
value: unknown;
|
|
66
|
+
defaultExpandedDepth?: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface YAMLViewerProps extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
|
|
70
|
+
value: string;
|
|
71
|
+
editable?: boolean;
|
|
72
|
+
onChange?: (value: string) => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface SchemaViewerProps extends React.HTMLAttributes<HTMLElement> {
|
|
76
|
+
schema: object;
|
|
77
|
+
validationState?: "valid" | "invalid" | "warning";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface APIEndpoint extends Record<string, unknown> {
|
|
81
|
+
id: string;
|
|
82
|
+
method: string;
|
|
83
|
+
path: string;
|
|
84
|
+
summary?: string;
|
|
85
|
+
headers?: Record<string, string> | string;
|
|
86
|
+
body?: unknown;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface APIRequest {
|
|
90
|
+
endpointId?: string;
|
|
91
|
+
method: string;
|
|
92
|
+
path: string;
|
|
93
|
+
headers: string;
|
|
94
|
+
body: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface APIExplorerProps extends Omit<React.HTMLAttributes<HTMLElement>, "onSelect"> {
|
|
98
|
+
endpoints: APIEndpoint[];
|
|
99
|
+
selectedId?: string;
|
|
100
|
+
onSelect?: (id: string) => void;
|
|
101
|
+
onSend?: (request: APIRequest) => unknown | Promise<unknown>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface EventPayloadViewerProps extends React.HTMLAttributes<HTMLElement> {
|
|
105
|
+
eventId?: string;
|
|
106
|
+
payload: unknown;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface LogEntry extends Record<string, unknown> {
|
|
110
|
+
id: string;
|
|
111
|
+
timestamp?: string;
|
|
112
|
+
level?: "debug" | "info" | "warn" | "error" | string;
|
|
113
|
+
message?: string;
|
|
114
|
+
text?: string;
|
|
115
|
+
source?: string;
|
|
116
|
+
stream?: "stdout" | "stderr";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface LogConsoleProps extends React.HTMLAttributes<HTMLElement> {
|
|
120
|
+
entries: LogEntry[];
|
|
121
|
+
onPause?: () => void;
|
|
122
|
+
streaming?: boolean;
|
|
123
|
+
filters?: React.ReactNode;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface TerminalLine extends Record<string, unknown> {
|
|
127
|
+
id: string;
|
|
128
|
+
stream: "stdout" | "stderr";
|
|
129
|
+
text: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface TerminalPanelProps extends React.HTMLAttributes<HTMLElement> {
|
|
133
|
+
lines: TerminalLine[];
|
|
134
|
+
prompt?: string;
|
|
135
|
+
onCommand?: (cmd: string) => void;
|
|
136
|
+
disabled?: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface TraceSpan extends Record<string, unknown> {
|
|
140
|
+
id: string;
|
|
141
|
+
name: string;
|
|
142
|
+
startMs: number;
|
|
143
|
+
durationMs: number;
|
|
144
|
+
status?: EthOperationalStatus;
|
|
145
|
+
parentId?: string;
|
|
146
|
+
service?: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface TraceTimelineProps extends React.HTMLAttributes<HTMLElement> {
|
|
150
|
+
spans: TraceSpan[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface HTTPMessage {
|
|
154
|
+
method?: string;
|
|
155
|
+
url?: string;
|
|
156
|
+
status?: number;
|
|
157
|
+
headers?: Record<string, string>;
|
|
158
|
+
body?: unknown;
|
|
159
|
+
durationMs?: number;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface RequestResponseViewerProps extends React.HTMLAttributes<HTMLElement> {
|
|
163
|
+
request: { method: string; url: string; headers?: Record<string, string>; body?: unknown };
|
|
164
|
+
response: {
|
|
165
|
+
status: number;
|
|
166
|
+
headers?: Record<string, string>;
|
|
167
|
+
body?: unknown;
|
|
168
|
+
durationMs?: number;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface WebhookEvent extends Record<string, unknown> {
|
|
173
|
+
id: string;
|
|
174
|
+
url: string;
|
|
175
|
+
status: string;
|
|
176
|
+
retries: number;
|
|
177
|
+
deliveredAt?: string;
|
|
178
|
+
payload: unknown;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface WebhookEventViewerProps extends React.HTMLAttributes<HTMLElement> {
|
|
182
|
+
events: WebhookEvent[];
|
|
183
|
+
onRetry?: (id: string) => void;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface GitRepositoryPanelProps extends React.HTMLAttributes<HTMLElement> {
|
|
187
|
+
repo: {
|
|
188
|
+
name: string;
|
|
189
|
+
url: string;
|
|
190
|
+
defaultBranch: string;
|
|
191
|
+
openPrCount?: number;
|
|
192
|
+
commitCount?: number;
|
|
193
|
+
lastCommitAt?: string;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface PullRequestPanelProps extends React.HTMLAttributes<HTMLElement> {
|
|
198
|
+
pr: {
|
|
199
|
+
id: string;
|
|
200
|
+
title: string;
|
|
201
|
+
body?: string;
|
|
202
|
+
state: string;
|
|
203
|
+
author: string;
|
|
204
|
+
reviewers?: string[];
|
|
205
|
+
commits?: number;
|
|
206
|
+
files?: Array<{ path: string; additions: number; deletions: number }>;
|
|
207
|
+
};
|
|
208
|
+
onApprove?: () => void;
|
|
209
|
+
onComment?: (comment: string) => void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface CommitRow extends Record<string, unknown> {
|
|
213
|
+
sha: string;
|
|
214
|
+
message: string;
|
|
215
|
+
author: string;
|
|
216
|
+
date: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface CommitListProps extends React.HTMLAttributes<HTMLElement> {
|
|
220
|
+
commits: CommitRow[];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface BranchSelectorProps extends Omit<
|
|
224
|
+
SelectProps,
|
|
225
|
+
"children" | "onChange" | "options" | "value"
|
|
226
|
+
> {
|
|
227
|
+
branches: string[];
|
|
228
|
+
value?: string;
|
|
229
|
+
onChange?: (branch: string) => void;
|
|
230
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import "./styles.css";
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
APIEndpoint,
|
|
5
|
+
APIExplorerProps,
|
|
6
|
+
APIRequest,
|
|
7
|
+
BranchSelectorProps,
|
|
8
|
+
CodeBlockProps,
|
|
9
|
+
CodeEditorProps,
|
|
10
|
+
CommitListProps,
|
|
11
|
+
CommitRow,
|
|
12
|
+
DiffTableChangeType,
|
|
13
|
+
DiffTableProps,
|
|
14
|
+
DiffTableRow,
|
|
15
|
+
DiffViewerProps,
|
|
16
|
+
EventPayloadViewerProps,
|
|
17
|
+
GitRepositoryPanelProps,
|
|
18
|
+
HTTPMessage,
|
|
19
|
+
JSONViewerProps,
|
|
20
|
+
LogConsoleProps,
|
|
21
|
+
LogEntry,
|
|
22
|
+
PullRequestPanelProps,
|
|
23
|
+
RequestResponseViewerProps,
|
|
24
|
+
SchemaViewerProps,
|
|
25
|
+
TerminalLine,
|
|
26
|
+
TerminalPanelProps,
|
|
27
|
+
TraceSpan,
|
|
28
|
+
TraceTimelineProps,
|
|
29
|
+
WebhookEvent,
|
|
30
|
+
WebhookEventViewerProps,
|
|
31
|
+
YAMLViewerProps
|
|
32
|
+
} from "./components/types";
|
|
33
|
+
export { APIExplorer } from "./components/APIExplorer";
|
|
34
|
+
export { BranchSelector } from "./components/BranchSelector";
|
|
35
|
+
export { CodeBlock } from "./components/CodeBlock";
|
|
36
|
+
export { CodeEditor } from "./components/CodeEditor";
|
|
37
|
+
export { CommitList } from "./components/CommitList";
|
|
38
|
+
export { DiffTable } from "./components/DiffTable";
|
|
39
|
+
export { DiffViewer } from "./components/DiffViewer";
|
|
40
|
+
export { EventPayloadViewer } from "./components/EventPayloadViewer";
|
|
41
|
+
export { GitRepositoryPanel } from "./components/GitRepositoryPanel";
|
|
42
|
+
export { JSONViewer } from "./components/JSONViewer";
|
|
43
|
+
export { LogConsole } from "./components/LogConsole";
|
|
44
|
+
export { PullRequestPanel } from "./components/PullRequestPanel";
|
|
45
|
+
export { RequestResponseViewer } from "./components/RequestResponseViewer";
|
|
46
|
+
export { SchemaViewer } from "./components/SchemaViewer";
|
|
47
|
+
export { TerminalPanel } from "./components/TerminalPanel";
|
|
48
|
+
export { TraceTimeline } from "./components/TraceTimeline";
|
|
49
|
+
export { WebhookEventViewer } from "./components/WebhookEventViewer";
|
|
50
|
+
export { YAMLViewer } from "./components/YAMLViewer";
|
|
51
|
+
|
|
52
|
+
export const DeveloperComponentNames = [
|
|
53
|
+
"CodeBlock",
|
|
54
|
+
"CodeEditor",
|
|
55
|
+
"DiffTable",
|
|
56
|
+
"DiffViewer",
|
|
57
|
+
"JSONViewer",
|
|
58
|
+
"YAMLViewer",
|
|
59
|
+
"SchemaViewer",
|
|
60
|
+
"APIExplorer",
|
|
61
|
+
"EventPayloadViewer",
|
|
62
|
+
"LogConsole",
|
|
63
|
+
"TerminalPanel",
|
|
64
|
+
"TraceTimeline",
|
|
65
|
+
"RequestResponseViewer",
|
|
66
|
+
"WebhookEventViewer",
|
|
67
|
+
"GitRepositoryPanel",
|
|
68
|
+
"PullRequestPanel",
|
|
69
|
+
"CommitList",
|
|
70
|
+
"BranchSelector"
|
|
71
|
+
] as const;
|
|
72
|
+
export type DeveloperComponentName = (typeof DeveloperComponentNames)[number];
|