@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.
Files changed (92) hide show
  1. package/.eslintrc.js +9 -0
  2. package/README.md +24 -0
  3. package/dist/es/assets/logo-plain.16842bbc.svg +70 -0
  4. package/dist/es/assets/logo-plain2.16842bbc.svg +70 -0
  5. package/dist/es/component/blackboard.css +25 -0
  6. package/dist/es/component/blackboard.js +256 -0
  7. package/dist/es/component/color.js +34 -0
  8. package/dist/es/component/common.css +0 -0
  9. package/dist/es/component/detail-panel.css +34 -0
  10. package/dist/es/component/detail-panel.js +106 -0
  11. package/dist/es/component/detail-side.css +99 -0
  12. package/dist/es/component/detail-side.js +285 -0
  13. package/dist/es/component/global-hover-preview.css +19 -0
  14. package/dist/es/component/global-hover-preview.js +44 -0
  15. package/dist/es/component/misc.js +24 -0
  16. package/dist/es/component/panel-title.css +8 -0
  17. package/dist/es/component/panel-title.js +9 -0
  18. package/dist/es/component/side-item.js +0 -0
  19. package/dist/es/component/sidebar.css +87 -0
  20. package/dist/es/component/sidebar.js +175 -0
  21. package/dist/es/component/store.js +128 -0
  22. package/dist/es/component/timeline.css +18 -0
  23. package/dist/es/component/timeline.js +438 -0
  24. package/dist/es/index.css +89 -0
  25. package/dist/es/index.js +174 -0
  26. package/dist/es/utils.js +76 -0
  27. package/dist/lib/assets/logo-plain.16842bbc.svg +70 -0
  28. package/dist/lib/assets/logo-plain2.16842bbc.svg +70 -0
  29. package/dist/lib/component/blackboard.css +25 -0
  30. package/dist/lib/component/blackboard.js +286 -0
  31. package/dist/lib/component/color.js +59 -0
  32. package/dist/lib/component/common.css +0 -0
  33. package/dist/lib/component/detail-panel.css +34 -0
  34. package/dist/lib/component/detail-panel.js +136 -0
  35. package/dist/lib/component/detail-side.css +99 -0
  36. package/dist/lib/component/detail-side.js +313 -0
  37. package/dist/lib/component/global-hover-preview.css +19 -0
  38. package/dist/lib/component/global-hover-preview.js +64 -0
  39. package/dist/lib/component/misc.js +48 -0
  40. package/dist/lib/component/panel-title.css +8 -0
  41. package/dist/lib/component/panel-title.js +29 -0
  42. package/dist/lib/component/side-item.js +1 -0
  43. package/dist/lib/component/sidebar.css +87 -0
  44. package/dist/lib/component/sidebar.js +198 -0
  45. package/dist/lib/component/store.js +153 -0
  46. package/dist/lib/component/timeline.css +18 -0
  47. package/dist/lib/component/timeline.js +466 -0
  48. package/dist/lib/index.css +89 -0
  49. package/dist/lib/index.js +202 -0
  50. package/dist/lib/utils.js +111 -0
  51. package/dist/types/component/blackboard.d.ts +4 -0
  52. package/dist/types/component/color.d.ts +2 -0
  53. package/dist/types/component/detail-panel.d.ts +4 -0
  54. package/dist/types/component/detail-side.d.ts +4 -0
  55. package/dist/types/component/global-hover-preview.d.ts +4 -0
  56. package/dist/types/component/misc.d.ts +2 -0
  57. package/dist/types/component/panel-title.d.ts +6 -0
  58. package/dist/types/component/side-item.d.ts +0 -0
  59. package/dist/types/component/sidebar.d.ts +4 -0
  60. package/dist/types/component/store.d.ts +35 -0
  61. package/dist/types/component/timeline.d.ts +4 -0
  62. package/dist/types/index.d.ts +4 -0
  63. package/dist/types/utils.d.ts +5 -0
  64. package/docs/index.tsx +6 -0
  65. package/modern.config.ts +15 -0
  66. package/package.json +46 -0
  67. package/src/component/assets/logo-plain.svg +70 -0
  68. package/src/component/assets/logo-plain2.svg +70 -0
  69. package/src/component/blackboard.less +37 -0
  70. package/src/component/blackboard.tsx +293 -0
  71. package/src/component/color.tsx +34 -0
  72. package/src/component/common.less +21 -0
  73. package/src/component/detail-panel.less +47 -0
  74. package/src/component/detail-panel.tsx +124 -0
  75. package/src/component/detail-side.less +131 -0
  76. package/src/component/detail-side.tsx +361 -0
  77. package/src/component/global-hover-preview.less +23 -0
  78. package/src/component/global-hover-preview.tsx +50 -0
  79. package/src/component/misc.tsx +20 -0
  80. package/src/component/panel-title.less +11 -0
  81. package/src/component/panel-title.tsx +11 -0
  82. package/src/component/side-item.tsx +0 -0
  83. package/src/component/sidebar.less +122 -0
  84. package/src/component/sidebar.tsx +205 -0
  85. package/src/component/store.tsx +151 -0
  86. package/src/component/timeline.less +25 -0
  87. package/src/component/timeline.tsx +486 -0
  88. package/src/global.d.ts +11 -0
  89. package/src/index.less +113 -0
  90. package/src/index.tsx +210 -0
  91. package/src/utils.ts +58 -0
  92. package/tsconfig.json +24 -0
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var detail_panel_exports = {};
31
+ __export(detail_panel_exports, {
32
+ default: () => detail_panel_default
33
+ });
34
+ module.exports = __toCommonJS(detail_panel_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_detail_panel = require("./detail-panel.css");
37
+ var import_antd = require("antd");
38
+ var import_icons = require("@ant-design/icons");
39
+ var import_react = require("react");
40
+ var import_blackboard = __toESM(require("./blackboard"));
41
+ var import_store = require("./store");
42
+ var import_utils = require("../utils");
43
+ const ScreenshotItem = (props) => {
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "screenshot-item", children: [
45
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "screenshot-item-title", children: props.time }),
46
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: props.img }) })
47
+ ] });
48
+ };
49
+ const VIEW_TYPE_SCREENSHOT = "screenshot";
50
+ const VIEW_TYPE_JSON = "json";
51
+ const VIEW_TYPE_BLACKBOARD = "blackboard";
52
+ const DetailPanel = () => {
53
+ var _a;
54
+ const dumpId = (0, import_store.useInsightDump)((store) => store._loadId);
55
+ const blackboardViewAvailable = Boolean(dumpId);
56
+ const activeTask = (0, import_store.useExecutionDump)((store) => store.activeTask);
57
+ const [preferredViewType, setViewType] = (0, import_react.useState)(dumpId ? VIEW_TYPE_BLACKBOARD : VIEW_TYPE_SCREENSHOT);
58
+ const viewType = preferredViewType === VIEW_TYPE_BLACKBOARD && !dumpId ? VIEW_TYPE_SCREENSHOT : preferredViewType;
59
+ let content;
60
+ if (!activeTask) {
61
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "please select a task" });
62
+ } else if (viewType === VIEW_TYPE_JSON) {
63
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "json-content", children: (0, import_utils.filterBase64Value)(JSON.stringify(activeTask, void 0, 2)) });
64
+ } else if (viewType === VIEW_TYPE_BLACKBOARD) {
65
+ if (dumpId) {
66
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_blackboard.default, {}, `${dumpId}`);
67
+ } else {
68
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "invalid view" });
69
+ }
70
+ } else if (viewType === VIEW_TYPE_SCREENSHOT) {
71
+ if ((_a = activeTask.recorder) == null ? void 0 : _a.length) {
72
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: activeTask.recorder.filter((item) => item.screenshot).map((item, index) => {
73
+ const fullTime = (0, import_utils.timeStr)(item.ts);
74
+ const str = item.timing ? `${fullTime} / ${item.timing}` : fullTime;
75
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScreenshotItem, { time: str, img: item.screenshot }, index);
76
+ }) });
77
+ } else {
78
+ content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "no screenshot" });
79
+ }
80
+ }
81
+ (0, import_react.useEffect)(() => {
82
+ const handleKeyDown = (e) => {
83
+ if (e.key === "Tab") {
84
+ if (viewType === VIEW_TYPE_BLACKBOARD) {
85
+ setViewType(VIEW_TYPE_SCREENSHOT);
86
+ } else if (viewType === VIEW_TYPE_SCREENSHOT) {
87
+ setViewType(VIEW_TYPE_JSON);
88
+ } else {
89
+ setViewType(blackboardViewAvailable ? VIEW_TYPE_BLACKBOARD : VIEW_TYPE_SCREENSHOT);
90
+ }
91
+ e.preventDefault();
92
+ }
93
+ };
94
+ document.addEventListener("keydown", handleKeyDown);
95
+ return () => {
96
+ document.removeEventListener("keydown", handleKeyDown);
97
+ };
98
+ });
99
+ const options = [
100
+ { label: "Screenshots", value: VIEW_TYPE_SCREENSHOT, icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CameraOutlined, {}) },
101
+ { label: "JSON View", value: VIEW_TYPE_JSON, icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.FileTextOutlined, {}) }
102
+ ];
103
+ if (blackboardViewAvailable) {
104
+ options.unshift({ label: "Visualization", value: VIEW_TYPE_BLACKBOARD, icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ScheduleOutlined, {}) });
105
+ }
106
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "detail-panel", children: [
107
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "view-switcher", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
+ import_antd.ConfigProvider,
109
+ {
110
+ theme: {
111
+ components: {
112
+ Segmented: {
113
+ itemSelectedBg: "#D7D7D7",
114
+ itemSelectedColor: "#000000"
115
+ // itemHoverColor: '#ffffff',
116
+ // itemHoverBg: '#A3D6D2', // @sub-blue
117
+ /* 这里是你的组件 token */
118
+ }
119
+ }
120
+ },
121
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
122
+ import_antd.Segmented,
123
+ {
124
+ options,
125
+ value: viewType,
126
+ onChange: (value) => {
127
+ setViewType(value);
128
+ }
129
+ }
130
+ )
131
+ }
132
+ ) }),
133
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "detail-content", children: content })
134
+ ] });
135
+ };
136
+ var detail_panel_default = DetailPanel;
@@ -0,0 +1,99 @@
1
+ .detail-side h2 {
2
+ padding-top: 0;
3
+ margin-top: 0;
4
+ margin-bottom: 4px;
5
+ }
6
+ .detail-side .ant-tag {
7
+ margin-top: 2px;
8
+ }
9
+ .detail-side .meta-kv {
10
+ padding: 10px 10px calc(10px + 4px);
11
+ }
12
+ .detail-side .meta-kv .meta {
13
+ box-sizing: border-box;
14
+ padding: 2px 0;
15
+ width: 100%;
16
+ display: flex;
17
+ flex-direction: row;
18
+ line-height: 1.5;
19
+ }
20
+ .detail-side .meta-kv .meta .meta-key {
21
+ width: 100px;
22
+ text-align: right;
23
+ padding-right: 10px;
24
+ }
25
+ .detail-side .meta-kv .meta .meta-value {
26
+ flex: 1 1;
27
+ }
28
+ .detail-side .item-list {
29
+ padding: 10px 10px;
30
+ cursor: default;
31
+ margin-bottom: 10px;
32
+ }
33
+ .detail-side .item-list .item {
34
+ padding: 16px 10px 10px;
35
+ transition: 0.1s;
36
+ border: 1px solid #DDD;
37
+ border-radius: 5px;
38
+ margin-bottom: 10px;
39
+ position: relative;
40
+ }
41
+ .detail-side .item-list .item.item-lite {
42
+ border: none;
43
+ padding: 0;
44
+ }
45
+ .detail-side .item-list .item-highlight {
46
+ color: #FFF;
47
+ }
48
+ .detail-side .item-list .item-highlight .subtitle {
49
+ color: #CCC;
50
+ }
51
+ .detail-side .item-list .item-extra {
52
+ position: absolute;
53
+ right: 10px;
54
+ top: 10px;
55
+ color: #777;
56
+ }
57
+ .detail-side .item-list .title-right-padding {
58
+ padding-right: 15px;
59
+ }
60
+ .detail-side .item-list .title {
61
+ font-size: 18px;
62
+ font-weight: bold;
63
+ margin-bottom: 5px;
64
+ }
65
+ .detail-side .item-list .title .title-tag {
66
+ display: inline-block;
67
+ margin-left: 6px;
68
+ color: #777;
69
+ font-size: 14px;
70
+ line-height: 18px;
71
+ }
72
+ .detail-side .item-list .subtitle {
73
+ font-weight: normal;
74
+ font-size: 14px;
75
+ color: #777;
76
+ }
77
+ .detail-side .item-list .description {
78
+ margin-top: 5px;
79
+ }
80
+ .detail-side .item-list .description-content {
81
+ font-size: 14px;
82
+ margin-top: 10px;
83
+ white-space: break-spaces;
84
+ margin: 0;
85
+ }
86
+ .detail-side .item-list .element-button:hover {
87
+ color: #fff;
88
+ background: #F9483E;
89
+ }
90
+ .detail-side .item-list .section-button:hover {
91
+ color: #fff;
92
+ background: #01204E;
93
+ }
94
+ .detail-side .context pre {
95
+ text-wrap: balance;
96
+ }
97
+ .detail-side .item-list-space-up {
98
+ margin-top: 10px;
99
+ }
@@ -0,0 +1,313 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
+ // If the importer is in node compatibility mode or this is not an ESM
37
+ // file that has been converted to a CommonJS file using a Babel-
38
+ // compatible transform (i.e. "__esModule" has not been set), then set
39
+ // "default" to the CommonJS "module.exports" for node compatibility.
40
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
+ mod
42
+ ));
43
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
44
+ var detail_side_exports = {};
45
+ __export(detail_side_exports, {
46
+ default: () => detail_side_default
47
+ });
48
+ module.exports = __toCommonJS(detail_side_exports);
49
+ var import_jsx_runtime = require("react/jsx-runtime");
50
+ var import_detail_side = require("./detail-side.css");
51
+ var import_icons = require("@ant-design/icons");
52
+ var import_antd = require("antd");
53
+ var import_color = require("./color");
54
+ var import_store = require("./store");
55
+ var import_panel_title = __toESM(require("./panel-title"));
56
+ var import_misc = require("./misc");
57
+ var import_utils = require("../utils");
58
+ const noop = () => {
59
+ };
60
+ const Card = (props) => {
61
+ const { highlightWithColor, title, subtitle, onMouseEnter, onMouseLeave, content, characteristic } = props;
62
+ const titleTag = props.characteristic ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "item-extra", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "title-tag", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { placement: "bottomRight", title: characteristic, mouseEnterDelay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.RadiusSettingOutlined, {}) }) }) }) }) : null;
63
+ const titleRightPaddingClass = props.characteristic ? "title-right-padding" : "";
64
+ const modeClass = props.liteMode ? "item-lite" : "";
65
+ const highlightStyle = highlightWithColor ? { backgroundColor: highlightWithColor } : {};
66
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
67
+ "div",
68
+ {
69
+ className: `item ${modeClass} ${highlightWithColor ? "item-highlight" : ""}`,
70
+ style: __spreadValues({}, highlightStyle),
71
+ onMouseEnter,
72
+ onMouseLeave,
73
+ children: [
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `title ${titleRightPaddingClass}`, style: { display: title ? "block" : "none" }, children: [
75
+ title,
76
+ titleTag
77
+ ] }),
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `subtitle ${titleRightPaddingClass}`, style: { display: subtitle ? "block" : "none" }, children: subtitle }),
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "description", style: { display: content ? "block" : "none" }, children: content })
80
+ ]
81
+ }
82
+ );
83
+ };
84
+ const MetaKV = (props) => {
85
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "meta-kv", children: props.data.map((item, index) => {
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "meta", children: [
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "meta-key", children: item.key }),
88
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "meta-value", children: item.content })
89
+ ] }, index);
90
+ }) });
91
+ };
92
+ const objectWithoutKeys = (obj, keys) => Object.keys(obj).reduce((acc, key) => {
93
+ if (!keys.includes(key)) {
94
+ acc[key] = obj[key];
95
+ }
96
+ return acc;
97
+ }, {});
98
+ const DetailSide = () => {
99
+ var _a, _b, _c, _d, _e, _f, _g, _h;
100
+ const task = (0, import_store.useExecutionDump)((store) => store.activeTask);
101
+ const dump = (0, import_store.useInsightDump)((store) => store.data);
102
+ const { matchedSection: sections, matchedElement: elements } = dump || {};
103
+ const highlightSectionNames = (0, import_store.useInsightDump)((store) => store.highlightSectionNames);
104
+ const highlightElements = (0, import_store.useInsightDump)((store) => store.highlightElements);
105
+ const setHighlightSectionNames = (0, import_store.useInsightDump)((store) => store.setHighlightSectionNames);
106
+ const setHighlightElements = (0, import_store.useInsightDump)((store) => store.setHighlightElements);
107
+ const setHighlightSectionName = function(name) {
108
+ setHighlightSectionNames([name]);
109
+ };
110
+ const setHighlightElement = function(element) {
111
+ setHighlightElements([element]);
112
+ };
113
+ const unhighlightSection = function() {
114
+ setHighlightSectionNames([]);
115
+ };
116
+ const unhighlightElement = function() {
117
+ setHighlightElements([]);
118
+ };
119
+ const kv = function(data) {
120
+ const isElementItem = (value) => Boolean(value) && typeof value === "object" && typeof value.content !== "undefined" && Boolean(value.center) && Boolean(value.rect);
121
+ const isSectionItem = (value) => Boolean(value) && typeof (value == null ? void 0 : value.sectionCharacteristics) !== "undefined" && typeof (value == null ? void 0 : value.rect) !== "undefined";
122
+ const elementEl = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
123
+ "span",
124
+ {
125
+ onMouseEnter: () => {
126
+ setHighlightElement(value);
127
+ },
128
+ onMouseLeave: unhighlightElement,
129
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tag, { bordered: false, color: "orange", className: "element-button", children: "Element" })
130
+ }
131
+ );
132
+ const sectionEl = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
+ "span",
134
+ {
135
+ onMouseEnter: () => {
136
+ setHighlightSectionName(value.name);
137
+ },
138
+ onMouseLeave: unhighlightSection,
139
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tag, { bordered: false, color: "blue", className: "section-button", children: "Section" })
140
+ }
141
+ );
142
+ if (Array.isArray(data) || typeof data !== "object") {
143
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "description-content", children: JSON.stringify(data, void 0, 2) });
144
+ }
145
+ return Object.keys(data).map((key) => {
146
+ const value = data[key];
147
+ let content;
148
+ if (typeof value === "object" && isElementItem(value)) {
149
+ content = elementEl(value);
150
+ } else if (Array.isArray(value) && value.some((item) => isElementItem(item))) {
151
+ content = value.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: elementEl(item) }, index));
152
+ } else if (typeof value === "object" && isSectionItem(value)) {
153
+ content = sectionEl(value);
154
+ } else if (Array.isArray(value) && value.some((item) => isSectionItem(item))) {
155
+ content = value.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: sectionEl(item) }, index));
156
+ } else {
157
+ content = typeof value === "string" ? value : JSON.stringify(value, void 0, 2);
158
+ }
159
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("pre", { className: "description-content", children: [
160
+ key,
161
+ ": ",
162
+ content
163
+ ] }, key);
164
+ });
165
+ };
166
+ const metaKVElement = MetaKV({
167
+ data: [
168
+ {
169
+ key: "Status",
170
+ content: (task == null ? void 0 : task.status) || ""
171
+ },
172
+ {
173
+ key: "Start",
174
+ content: (0, import_utils.timeStr)((_a = task == null ? void 0 : task.timing) == null ? void 0 : _a.start)
175
+ },
176
+ {
177
+ key: "End",
178
+ content: (0, import_utils.timeStr)((_b = task == null ? void 0 : task.timing) == null ? void 0 : _b.end)
179
+ },
180
+ {
181
+ key: "Time Cost",
182
+ content: (0, import_misc.timeCostStrElement)((_c = task == null ? void 0 : task.timing) == null ? void 0 : _c.cost)
183
+ }
184
+ ]
185
+ });
186
+ let taskParam = null;
187
+ if ((task == null ? void 0 : task.type) === "Planning") {
188
+ taskParam = MetaKV({
189
+ data: [
190
+ { key: "type", content: task && (0, import_utils.typeStr)(task) || "" },
191
+ { key: "param", content: (_d = task == null ? void 0 : task.param) == null ? void 0 : _d.userPrompt }
192
+ ]
193
+ });
194
+ } else if ((task == null ? void 0 : task.type) === "Insight") {
195
+ taskParam = MetaKV({
196
+ data: [
197
+ { key: "type", content: task && (0, import_utils.typeStr)(task) || "" },
198
+ {
199
+ key: "param",
200
+ content: JSON.stringify(
201
+ ((_e = task == null ? void 0 : task.param) == null ? void 0 : _e.prompt) || ((_f = task == null ? void 0 : task.param) == null ? void 0 : _f.dataDemand)
202
+ )
203
+ }
204
+ ]
205
+ });
206
+ } else if ((task == null ? void 0 : task.type) === "Action") {
207
+ taskParam = MetaKV({
208
+ data: [
209
+ { key: "type", content: task && (0, import_utils.typeStr)(task) || "" },
210
+ {
211
+ key: "value",
212
+ content: JSON.stringify((_g = task == null ? void 0 : task.param) == null ? void 0 : _g.value, void 0, 2)
213
+ }
214
+ ]
215
+ });
216
+ }
217
+ const matchedSectionsEl = (sections == null ? void 0 : sections.length) ? sections.map((section) => {
218
+ const { name } = section;
219
+ const ifHighlight = highlightSectionNames.includes(name);
220
+ const kvToShow = objectWithoutKeys(section, [
221
+ "name",
222
+ "description",
223
+ "texts",
224
+ "rect",
225
+ "sectionCharacteristics"
226
+ ]);
227
+ const sectionKV = Object.keys(kvToShow).length ? kv(kvToShow) : null;
228
+ const highlightColor = ifHighlight ? (0, import_color.highlightColorForType)("section") : void 0;
229
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
230
+ Card,
231
+ {
232
+ title: section.name,
233
+ highlightWithColor: highlightColor,
234
+ subtitle: section.description,
235
+ characteristic: section.sectionCharacteristics,
236
+ onMouseEnter: setHighlightSectionName.bind(void 0, name),
237
+ onMouseLeave: unhighlightSection,
238
+ content: sectionKV
239
+ },
240
+ name
241
+ );
242
+ }) : null;
243
+ const matchedElementsEl = (elements == null ? void 0 : elements.length) ? elements.map((element, idx) => {
244
+ const ifHighlight = highlightElements.includes(element);
245
+ const highlightColor = ifHighlight ? (0, import_color.highlightColorForType)("element") : void 0;
246
+ const elementKV = kv(
247
+ objectWithoutKeys(element, [
248
+ "content",
249
+ "rect",
250
+ "center",
251
+ "left",
252
+ "top",
253
+ "right",
254
+ "bottom",
255
+ "locator"
256
+ ])
257
+ );
258
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
259
+ Card,
260
+ {
261
+ title: element.content,
262
+ highlightWithColor: highlightColor,
263
+ subtitle: "",
264
+ onMouseEnter: setHighlightElement.bind(void 0, element),
265
+ onMouseLeave: unhighlightElement,
266
+ content: elementKV
267
+ },
268
+ idx
269
+ );
270
+ }) : null;
271
+ const errorSection = (dump == null ? void 0 : dump.error) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
272
+ Card,
273
+ {
274
+ liteMode: true,
275
+ title: "Error",
276
+ onMouseEnter: noop,
277
+ onMouseLeave: noop,
278
+ content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "description-content", style: { color: "#F00" }, children: dump.error })
279
+ }
280
+ ) : null;
281
+ const dataCard = (dump == null ? void 0 : dump.data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { liteMode: true, onMouseEnter: noop, onMouseLeave: noop, content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: kv(dump.data) }) }) : null;
282
+ const plans = (_h = task == null ? void 0 : task.output) == null ? void 0 : _h.plans;
283
+ let timelineData = [];
284
+ if (plans) {
285
+ timelineData = timelineData.concat(
286
+ plans.map((item) => {
287
+ return {
288
+ color: "#06B1AB",
289
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
290
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: (0, import_utils.typeStr)(item) }) }),
291
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: item.thought }),
292
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: item.param ? JSON.stringify(item.param || {}, void 0, 2) : null })
293
+ ] })
294
+ };
295
+ })
296
+ );
297
+ }
298
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "detail-side", children: [
299
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_panel_title.default, { title: "Task Meta" }),
300
+ metaKVElement,
301
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_panel_title.default, { title: "Param" }),
302
+ taskParam,
303
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_panel_title.default, { title: "Output" }),
304
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "item-list item-list-space-up", children: [
305
+ errorSection,
306
+ dataCard,
307
+ matchedSectionsEl,
308
+ matchedElementsEl,
309
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Timeline, { items: timelineData })
310
+ ] })
311
+ ] });
312
+ };
313
+ var detail_side_default = DetailSide;
@@ -0,0 +1,19 @@
1
+ .global-hover-preview {
2
+ position: fixed;
3
+ display: block;
4
+ max-width: 400px;
5
+ max-height: 400px;
6
+ overflow: hidden;
7
+ z-index: 10;
8
+ text-align: center;
9
+ border: 1px solid #CCCCCC;
10
+ box-sizing: border-box;
11
+ background: #ECECEC;
12
+ box-shadow: 1px 1px 5px 0 rgba(0, 0, 0, 0.2);
13
+ }
14
+ .global-hover-preview img {
15
+ max-width: 400px;
16
+ max-height: 400px;
17
+ width: auto;
18
+ height: auto;
19
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var global_hover_preview_exports = {};
20
+ __export(global_hover_preview_exports, {
21
+ default: () => global_hover_preview_default
22
+ });
23
+ module.exports = __toCommonJS(global_hover_preview_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_react = require("react");
26
+ var import_store = require("./store");
27
+ var import_global_hover_preview = require("./global-hover-preview.css");
28
+ const size = 400;
29
+ const GlobalHoverPreview = () => {
30
+ var _a;
31
+ const wrapperRef = (0, import_react.useRef)(null);
32
+ const hoverTask = (0, import_store.useExecutionDump)((store) => store.hoverTask);
33
+ const hoverPreviewConfig = (0, import_store.useExecutionDump)((store) => store.hoverPreviewConfig);
34
+ const [imageW, setImageW] = (0, import_react.useState)(size);
35
+ const [imageH, setImageH] = (0, import_react.useState)(size);
36
+ const images = (_a = hoverTask == null ? void 0 : hoverTask.recorder) == null ? void 0 : _a.filter((item) => {
37
+ return item.screenshot;
38
+ }).map((item) => item.screenshot);
39
+ const { x, y } = hoverPreviewConfig || {};
40
+ let left = 0;
41
+ let top = 0;
42
+ const shouldShow = (images == null ? void 0 : images.length) && typeof x !== "undefined" && typeof y !== "undefined";
43
+ if (shouldShow) {
44
+ const { clientWidth, clientHeight } = document.body;
45
+ const widthInPractice = imageW >= imageH ? size : size * (imageW / imageH);
46
+ const heightInPractice = imageW >= imageH ? size * (imageH / imageW) : size;
47
+ left = x + widthInPractice > clientWidth ? clientWidth - widthInPractice : x;
48
+ top = y + heightInPractice > clientHeight ? clientHeight - heightInPractice : y;
49
+ }
50
+ return shouldShow ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "global-hover-preview", style: { left, top }, ref: wrapperRef, children: (images == null ? void 0 : images.length) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
51
+ "img",
52
+ {
53
+ src: images[0],
54
+ onLoad: (img) => {
55
+ const imgElement = img.target;
56
+ const width = imgElement.naturalWidth;
57
+ const height = imgElement.naturalHeight;
58
+ setImageW(width);
59
+ setImageH(height);
60
+ }
61
+ }
62
+ ) : null }) : null;
63
+ };
64
+ var global_hover_preview_default = GlobalHoverPreview;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var misc_exports = {};
20
+ __export(misc_exports, {
21
+ timeCostStrElement: () => timeCostStrElement
22
+ });
23
+ module.exports = __toCommonJS(misc_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ function timeCostStrElement(timeCost) {
26
+ let str;
27
+ if (typeof timeCost !== "number") {
28
+ str = "- ms";
29
+ } else if (timeCost > 1e3) {
30
+ str = `${(timeCost / 1e3).toFixed(2)}s`;
31
+ } else {
32
+ str = `${timeCost}ms`;
33
+ }
34
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
35
+ "span",
36
+ {
37
+ style: {
38
+ fontVariantNumeric: "tabular-nums",
39
+ fontFeatureSettings: "tnum"
40
+ },
41
+ children: str
42
+ }
43
+ );
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ timeCostStrElement
48
+ });