@midscene/visualizer 0.0.1
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/.eslintrc.js +9 -0
- package/README.md +24 -0
- package/dist/es/assets/logo-plain.16842bbc.svg +70 -0
- package/dist/es/assets/logo-plain2.16842bbc.svg +70 -0
- package/dist/es/component/blackboard.css +25 -0
- package/dist/es/component/blackboard.js +256 -0
- package/dist/es/component/color.js +34 -0
- package/dist/es/component/common.css +0 -0
- package/dist/es/component/detail-panel.css +34 -0
- package/dist/es/component/detail-panel.js +106 -0
- package/dist/es/component/detail-side.css +99 -0
- package/dist/es/component/detail-side.js +285 -0
- package/dist/es/component/global-hover-preview.css +19 -0
- package/dist/es/component/global-hover-preview.js +44 -0
- package/dist/es/component/misc.js +24 -0
- package/dist/es/component/panel-title.css +8 -0
- package/dist/es/component/panel-title.js +9 -0
- package/dist/es/component/side-item.js +0 -0
- package/dist/es/component/sidebar.css +87 -0
- package/dist/es/component/sidebar.js +175 -0
- package/dist/es/component/store.js +128 -0
- package/dist/es/component/timeline.css +18 -0
- package/dist/es/component/timeline.js +438 -0
- package/dist/es/index.css +89 -0
- package/dist/es/index.js +174 -0
- package/dist/es/utils.js +76 -0
- package/dist/lib/assets/logo-plain.16842bbc.svg +70 -0
- package/dist/lib/assets/logo-plain2.16842bbc.svg +70 -0
- package/dist/lib/component/blackboard.css +25 -0
- package/dist/lib/component/blackboard.js +286 -0
- package/dist/lib/component/color.js +59 -0
- package/dist/lib/component/common.css +0 -0
- package/dist/lib/component/detail-panel.css +34 -0
- package/dist/lib/component/detail-panel.js +136 -0
- package/dist/lib/component/detail-side.css +99 -0
- package/dist/lib/component/detail-side.js +313 -0
- package/dist/lib/component/global-hover-preview.css +19 -0
- package/dist/lib/component/global-hover-preview.js +64 -0
- package/dist/lib/component/misc.js +48 -0
- package/dist/lib/component/panel-title.css +8 -0
- package/dist/lib/component/panel-title.js +29 -0
- package/dist/lib/component/side-item.js +1 -0
- package/dist/lib/component/sidebar.css +87 -0
- package/dist/lib/component/sidebar.js +198 -0
- package/dist/lib/component/store.js +153 -0
- package/dist/lib/component/timeline.css +18 -0
- package/dist/lib/component/timeline.js +466 -0
- package/dist/lib/index.css +89 -0
- package/dist/lib/index.js +202 -0
- package/dist/lib/utils.js +111 -0
- package/dist/types/component/blackboard.d.ts +4 -0
- package/dist/types/component/color.d.ts +2 -0
- package/dist/types/component/detail-panel.d.ts +4 -0
- package/dist/types/component/detail-side.d.ts +4 -0
- package/dist/types/component/global-hover-preview.d.ts +4 -0
- package/dist/types/component/misc.d.ts +2 -0
- package/dist/types/component/panel-title.d.ts +6 -0
- package/dist/types/component/side-item.d.ts +0 -0
- package/dist/types/component/sidebar.d.ts +4 -0
- package/dist/types/component/store.d.ts +35 -0
- package/dist/types/component/timeline.d.ts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/utils.d.ts +5 -0
- package/docs/index.tsx +6 -0
- package/modern.config.ts +15 -0
- package/package.json +46 -0
- package/src/component/assets/logo-plain.svg +70 -0
- package/src/component/assets/logo-plain2.svg +70 -0
- package/src/component/blackboard.less +37 -0
- package/src/component/blackboard.tsx +293 -0
- package/src/component/color.tsx +34 -0
- package/src/component/common.less +21 -0
- package/src/component/detail-panel.less +47 -0
- package/src/component/detail-panel.tsx +124 -0
- package/src/component/detail-side.less +131 -0
- package/src/component/detail-side.tsx +361 -0
- package/src/component/global-hover-preview.less +23 -0
- package/src/component/global-hover-preview.tsx +50 -0
- package/src/component/misc.tsx +20 -0
- package/src/component/panel-title.less +11 -0
- package/src/component/panel-title.tsx +11 -0
- package/src/component/side-item.tsx +0 -0
- package/src/component/sidebar.less +122 -0
- package/src/component/sidebar.tsx +205 -0
- package/src/component/store.tsx +151 -0
- package/src/component/timeline.less +25 -0
- package/src/component/timeline.tsx +486 -0
- package/src/global.d.ts +11 -0
- package/src/index.less +113 -0
- package/src/index.tsx +210 -0
- package/src/utils.ts +58 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "./sidebar.css";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import {
|
|
5
|
+
ArrowRightOutlined,
|
|
6
|
+
CheckOutlined,
|
|
7
|
+
ClockCircleOutlined,
|
|
8
|
+
CloseOutlined,
|
|
9
|
+
LogoutOutlined,
|
|
10
|
+
MinusOutlined
|
|
11
|
+
} from "@ant-design/icons";
|
|
12
|
+
import { Button } from "antd";
|
|
13
|
+
import PanelTitle from "./panel-title";
|
|
14
|
+
import { timeCostStrElement } from "./misc";
|
|
15
|
+
import logo from "../assets/logo-plain2.16842bbc.svg";
|
|
16
|
+
import { useAllCurrentTasks, useExecutionDump } from "./store";
|
|
17
|
+
import { typeStr } from "../utils";
|
|
18
|
+
const SideItem = (props) => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const { task, onClick, selected } = props;
|
|
21
|
+
const selectedClass = selected ? "selected" : "";
|
|
22
|
+
let statusIcon = /* @__PURE__ */ jsx(MinusOutlined, {});
|
|
23
|
+
if (task.status === "success") {
|
|
24
|
+
statusIcon = /* @__PURE__ */ jsx(CheckOutlined, {});
|
|
25
|
+
} else if (task.status === "fail") {
|
|
26
|
+
statusIcon = /* @__PURE__ */ jsx(CloseOutlined, {});
|
|
27
|
+
} else if (task.status === "pending") {
|
|
28
|
+
statusIcon = /* @__PURE__ */ jsx(ClockCircleOutlined, {});
|
|
29
|
+
} else if (task.status === "cancelled") {
|
|
30
|
+
statusIcon = /* @__PURE__ */ jsx(LogoutOutlined, {});
|
|
31
|
+
} else if (task.status === "running") {
|
|
32
|
+
statusIcon = /* @__PURE__ */ jsx(ArrowRightOutlined, {});
|
|
33
|
+
}
|
|
34
|
+
let statusText = task.status;
|
|
35
|
+
if ((_a = task.timing) == null ? void 0 : _a.cost) {
|
|
36
|
+
statusText = timeCostStrElement(task.timing.cost);
|
|
37
|
+
}
|
|
38
|
+
const contentRow = task.type === "Planning" ? /* @__PURE__ */ jsxs("div", { className: "side-item-content", children: [
|
|
39
|
+
(_b = task.param) == null ? void 0 : _b.userPrompt,
|
|
40
|
+
" "
|
|
41
|
+
] }) : null;
|
|
42
|
+
return /* @__PURE__ */ jsxs(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
className: `side-item ${selectedClass}`,
|
|
46
|
+
onClick,
|
|
47
|
+
onMouseEnter: (event) => {
|
|
48
|
+
var _a2;
|
|
49
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
50
|
+
const x = rect.left + rect.width;
|
|
51
|
+
const y = rect.top;
|
|
52
|
+
(_a2 = props.onItemHover) == null ? void 0 : _a2.call(props, task, x, y);
|
|
53
|
+
},
|
|
54
|
+
onMouseLeave: () => {
|
|
55
|
+
var _a2;
|
|
56
|
+
(_a2 = props.onItemHover) == null ? void 0 : _a2.call(props, null);
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
" ",
|
|
60
|
+
/* @__PURE__ */ jsxs("div", { className: `side-item-name`, children: [
|
|
61
|
+
/* @__PURE__ */ jsx("span", { className: `status-icon status-icon-${task.status}`, children: statusIcon }),
|
|
62
|
+
/* @__PURE__ */ jsx("div", { className: "title", children: typeStr(task) }),
|
|
63
|
+
/* @__PURE__ */ jsx("div", { className: "status-text", children: statusText })
|
|
64
|
+
] }),
|
|
65
|
+
contentRow
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
const Sidebar = () => {
|
|
71
|
+
const groupedDumps = useExecutionDump((store) => store.dump);
|
|
72
|
+
const setActiveTask = useExecutionDump((store) => store.setActiveTask);
|
|
73
|
+
const activeTask = useExecutionDump((store) => store.activeTask);
|
|
74
|
+
const setHoverTask = useExecutionDump((store) => store.setHoverTask);
|
|
75
|
+
const setHoverPreviewConfig = useExecutionDump((store) => store.setHoverPreviewConfig);
|
|
76
|
+
const reset = useExecutionDump((store) => store.reset);
|
|
77
|
+
const allTasks = useAllCurrentTasks();
|
|
78
|
+
const currentSelectedIndex = allTasks == null ? void 0 : allTasks.findIndex((task) => task === activeTask);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const handleKeyDown = (e) => {
|
|
81
|
+
if (!(allTasks == null ? void 0 : allTasks.length) || (allTasks == null ? void 0 : allTasks.length) <= 1) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (e.key === "ArrowUp" && (e.metaKey || e.ctrlKey)) {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
const nextIndex = currentSelectedIndex - 1;
|
|
87
|
+
if (nextIndex < 0) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const nextTask = allTasks[nextIndex];
|
|
91
|
+
setActiveTask(nextTask);
|
|
92
|
+
} else if (e.key === "ArrowDown" && (e.metaKey || e.ctrlKey)) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
const nextIndex = currentSelectedIndex + 1;
|
|
95
|
+
if (nextIndex >= allTasks.length) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const nextTask = allTasks[nextIndex];
|
|
99
|
+
setActiveTask(nextTask);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
103
|
+
return () => {
|
|
104
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
105
|
+
};
|
|
106
|
+
}, [currentSelectedIndex, allTasks, setActiveTask]);
|
|
107
|
+
const sideList = (groupedDumps == null ? void 0 : groupedDumps.length) ? groupedDumps.map((group, groupIndex) => {
|
|
108
|
+
const executions = group.executions.map((execution, indexOfExecution) => {
|
|
109
|
+
const { tasks } = execution;
|
|
110
|
+
const taskList = tasks.map((task, index) => {
|
|
111
|
+
return /* @__PURE__ */ jsx(
|
|
112
|
+
SideItem,
|
|
113
|
+
{
|
|
114
|
+
task,
|
|
115
|
+
selected: task === activeTask,
|
|
116
|
+
onClick: () => {
|
|
117
|
+
setActiveTask(task);
|
|
118
|
+
},
|
|
119
|
+
onItemHover: (hoverTask, x, y) => {
|
|
120
|
+
if (hoverTask && x && y) {
|
|
121
|
+
setHoverPreviewConfig({ x, y });
|
|
122
|
+
setHoverTask(hoverTask);
|
|
123
|
+
} else {
|
|
124
|
+
setHoverPreviewConfig(null);
|
|
125
|
+
setHoverTask(null);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
index
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
let seperator;
|
|
133
|
+
switch (indexOfExecution) {
|
|
134
|
+
case 0:
|
|
135
|
+
seperator = /* @__PURE__ */ jsx("div", { className: "side-seperator side-seperator-space-up" });
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
seperator = /* @__PURE__ */ jsx("div", { className: "side-seperator side-seperator-line side-seperator-space-up side-seperator-space-down" });
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
142
|
+
seperator,
|
|
143
|
+
/* @__PURE__ */ jsx("div", { className: "side-sub-title", children: execution.name }),
|
|
144
|
+
taskList
|
|
145
|
+
] }, indexOfExecution);
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
148
|
+
/* @__PURE__ */ jsx(PanelTitle, { title: group.groupName }),
|
|
149
|
+
executions
|
|
150
|
+
] }, groupIndex);
|
|
151
|
+
}) : /* @__PURE__ */ jsx("span", { children: "no tasks" });
|
|
152
|
+
return /* @__PURE__ */ jsxs("div", { className: "side-bar", children: [
|
|
153
|
+
/* @__PURE__ */ jsxs("div", { className: "top-controls", children: [
|
|
154
|
+
/* @__PURE__ */ jsx("div", { className: "brand", onClick: reset, children: /* @__PURE__ */ jsx(
|
|
155
|
+
"img",
|
|
156
|
+
{
|
|
157
|
+
src: logo,
|
|
158
|
+
alt: "Logo",
|
|
159
|
+
style: { width: 70, height: 70, margin: "auto" },
|
|
160
|
+
onClick: () => {
|
|
161
|
+
location.reload();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
) }),
|
|
165
|
+
/* @__PURE__ */ jsx("div", { className: "task-list", children: sideList }),
|
|
166
|
+
/* @__PURE__ */ jsx("div", { className: "side-seperator side-seperator-line side-seperator-space-up" }),
|
|
167
|
+
/* @__PURE__ */ jsx("div", { className: "task-meta-section", children: /* @__PURE__ */ jsx("div", { className: "task-meta", children: "use Command + ⬆︎ / ⬇︎ to switch" }) })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ jsx("div", { className: "bottom-controls", children: /* @__PURE__ */ jsx(Button, { onClick: reset, type: "text", className: "unload_btn", children: "Unload" }) })
|
|
170
|
+
] });
|
|
171
|
+
};
|
|
172
|
+
var sidebar_default = Sidebar;
|
|
173
|
+
export {
|
|
174
|
+
sidebar_default as default
|
|
175
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { create } from "zustand";
|
|
21
|
+
const useBlackboardPreference = create((set) => ({
|
|
22
|
+
bgVisible: false,
|
|
23
|
+
textsVisible: true,
|
|
24
|
+
setBgVisible: (visible) => {
|
|
25
|
+
set({ bgVisible: visible });
|
|
26
|
+
},
|
|
27
|
+
setTextsVisible: (visible) => {
|
|
28
|
+
set({ textsVisible: visible });
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
const useExecutionDump = create((set) => {
|
|
32
|
+
const initData = {
|
|
33
|
+
dump: null,
|
|
34
|
+
activeTask: null,
|
|
35
|
+
hoverTask: null,
|
|
36
|
+
hoverPreviewConfig: null
|
|
37
|
+
};
|
|
38
|
+
const syncToInsightDump = (dump) => {
|
|
39
|
+
const { loadData } = useInsightDump.getState();
|
|
40
|
+
loadData(dump);
|
|
41
|
+
};
|
|
42
|
+
const resetInsightDump = () => {
|
|
43
|
+
const { reset } = useInsightDump.getState();
|
|
44
|
+
reset();
|
|
45
|
+
};
|
|
46
|
+
return __spreadProps(__spreadValues({}, initData), {
|
|
47
|
+
setGroupedDump: (dump) => {
|
|
48
|
+
console.log("will set ExecutionDump", dump);
|
|
49
|
+
set({
|
|
50
|
+
dump
|
|
51
|
+
});
|
|
52
|
+
for (const item of dump) {
|
|
53
|
+
if (item.executions.length > 0 && item.executions[0].tasks.length > 0) {
|
|
54
|
+
set({ activeTask: item.executions[0].tasks[0] });
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
setActiveTask(task) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
set({ activeTask: task });
|
|
62
|
+
if ((_b = (_a = task.log) == null ? void 0 : _a.dump) == null ? void 0 : _b.matchedElement) {
|
|
63
|
+
syncToInsightDump(task.log.dump);
|
|
64
|
+
} else {
|
|
65
|
+
resetInsightDump();
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
setHoverTask(task) {
|
|
69
|
+
set({ hoverTask: task });
|
|
70
|
+
},
|
|
71
|
+
setHoverPreviewConfig(config) {
|
|
72
|
+
if (config) {
|
|
73
|
+
set({
|
|
74
|
+
hoverPreviewConfig: {
|
|
75
|
+
x: Math.floor(config.x),
|
|
76
|
+
y: Math.floor(config.y)
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
set({ hoverPreviewConfig: null });
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
reset: () => {
|
|
84
|
+
set(initData);
|
|
85
|
+
resetInsightDump();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const useAllCurrentTasks = () => {
|
|
90
|
+
const groupedDumps = useExecutionDump((store) => store.dump);
|
|
91
|
+
const allTasks = (groupedDumps == null ? void 0 : groupedDumps.reduce((acc, group) => {
|
|
92
|
+
const tasksInside = group.executions.reduce(
|
|
93
|
+
(acc2, execution) => acc2.concat(execution.tasks),
|
|
94
|
+
[]
|
|
95
|
+
);
|
|
96
|
+
return acc.concat(tasksInside);
|
|
97
|
+
}, [])) || [];
|
|
98
|
+
return allTasks;
|
|
99
|
+
};
|
|
100
|
+
const useInsightDump = create((set) => {
|
|
101
|
+
let loadId = 0;
|
|
102
|
+
const initData = { _loadId: 0, highlightSectionNames: [], highlightElements: [], data: null };
|
|
103
|
+
return __spreadProps(__spreadValues({}, initData), {
|
|
104
|
+
loadData: (data) => {
|
|
105
|
+
set({
|
|
106
|
+
_loadId: ++loadId,
|
|
107
|
+
data,
|
|
108
|
+
highlightSectionNames: [],
|
|
109
|
+
highlightElements: []
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
setHighlightSectionNames: (sections) => {
|
|
113
|
+
set({ highlightSectionNames: sections });
|
|
114
|
+
},
|
|
115
|
+
setHighlightElements: (elements) => {
|
|
116
|
+
set({ highlightElements: elements });
|
|
117
|
+
},
|
|
118
|
+
reset: () => {
|
|
119
|
+
set(initData);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
export {
|
|
124
|
+
useAllCurrentTasks,
|
|
125
|
+
useBlackboardPreference,
|
|
126
|
+
useExecutionDump,
|
|
127
|
+
useInsightDump
|
|
128
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.timeline-wrapper {
|
|
2
|
+
flex-basis: 110px;
|
|
3
|
+
flex-grow: 0;
|
|
4
|
+
flex-shrink: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
border-bottom: 1px solid #CCCCCC;
|
|
8
|
+
position: relative;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
11
|
+
.timeline-wrapper .timeline-canvas-wrapper {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
.timeline-wrapper canvas {
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
}
|