@midscene/visualizer 0.1.0 → 0.1.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.
@@ -72,7 +72,11 @@ const BlackBoard = () => {
72
72
  );
73
73
  return () => {
74
74
  console.log("will destroy");
75
- app == null ? void 0 : app.destroy(true, { children: true, texture: true });
75
+ try {
76
+ app.destroy(true, { children: true, texture: true });
77
+ } catch (e) {
78
+ console.warn("destroy failed", e);
79
+ }
76
80
  };
77
81
  }, [app, screenWidth, screenHeight]);
78
82
  useEffect(() => {
@@ -18,9 +18,10 @@
18
18
  line-height: 1.5;
19
19
  }
20
20
  .detail-side .meta-kv .meta .meta-key {
21
+ font-weight: bold;
21
22
  width: 100px;
22
23
  text-align: right;
23
- padding-right: 10px;
24
+ padding-right: 16px;
24
25
  }
25
26
  .detail-side .meta-kv .meta .meta-value {
26
27
  flex: 1 1;
@@ -135,19 +135,19 @@ const DetailSide = () => {
135
135
  const metaKVElement = MetaKV({
136
136
  data: [
137
137
  {
138
- key: "Status",
138
+ key: "status",
139
139
  content: (task == null ? void 0 : task.status) || ""
140
140
  },
141
141
  {
142
- key: "Start",
142
+ key: "start",
143
143
  content: timeStr((_a = task == null ? void 0 : task.timing) == null ? void 0 : _a.start)
144
144
  },
145
145
  {
146
- key: "End",
146
+ key: "end",
147
147
  content: timeStr((_b = task == null ? void 0 : task.timing) == null ? void 0 : _b.end)
148
148
  },
149
149
  {
150
- key: "Time Cost",
150
+ key: "time cost",
151
151
  content: timeCostStrElement((_c = task == null ? void 0 : task.timing) == null ? void 0 : _c.cost)
152
152
  }
153
153
  ]
@@ -7,11 +7,16 @@ const GlobalHoverPreview = () => {
7
7
  var _a;
8
8
  const wrapperRef = useRef(null);
9
9
  const hoverTask = useExecutionDump((store) => store.hoverTask);
10
+ const hoverTimestamp = useExecutionDump((store) => store.hoverTimestamp);
10
11
  const hoverPreviewConfig = useExecutionDump((store) => store.hoverPreviewConfig);
11
12
  const [imageW, setImageW] = useState(size);
12
13
  const [imageH, setImageH] = useState(size);
13
14
  const images = (_a = hoverTask == null ? void 0 : hoverTask.recorder) == null ? void 0 : _a.filter((item) => {
14
- return item.screenshot;
15
+ let valid = Boolean(item.screenshot);
16
+ if (hoverTimestamp) {
17
+ valid = valid && item.ts >= hoverTimestamp;
18
+ }
19
+ return valid;
15
20
  }).map((item) => item.screenshot);
16
21
  const { x, y } = hoverPreviewConfig || {};
17
22
  let left = 0;
@@ -33,6 +33,7 @@ const useExecutionDump = create((set, get) => {
33
33
  dump: null,
34
34
  activeTask: null,
35
35
  hoverTask: null,
36
+ hoverTimestamp: null,
36
37
  hoverPreviewConfig: null
37
38
  };
38
39
  const syncToInsightDump = (dump) => {
@@ -65,8 +66,8 @@ const useExecutionDump = create((set, get) => {
65
66
  resetInsightDump();
66
67
  }
67
68
  },
68
- setHoverTask(task) {
69
- set({ hoverTask: task });
69
+ setHoverTask(task, timestamp) {
70
+ set({ hoverTask: task, hoverTimestamp: timestamp || null });
70
71
  },
71
72
  setHoverPreviewConfig(config) {
72
73
  if (config) {
@@ -394,7 +394,7 @@ const Timeline = () => {
394
394
  const refBounding = (_a = wrapper.current) == null ? void 0 : _a.getBoundingClientRect();
395
395
  const task = idTaskMap[item.id];
396
396
  if (task) {
397
- setHoverTask(task);
397
+ setHoverTask(task, item.timeOffset + startingTime);
398
398
  setHoverPreviewConfig({
399
399
  x: mouseX + ((refBounding == null ? void 0 : refBounding.left) || 0),
400
400
  y: ((refBounding == null ? void 0 : refBounding.bottom) || 1) - 1
package/dist/es/index.css CHANGED
@@ -2,13 +2,9 @@ html,
2
2
  body {
3
3
  padding: 0;
4
4
  margin: 0;
5
- font-family:
6
- PingFang SC,
7
- Hiragino Sans GB,
8
- Microsoft YaHei,
9
- Arial,
10
- sans-serif;
11
- font-size: 14px;
5
+ }
6
+ .rspress-nav {
7
+ transition: 0.2s;
12
8
  }
13
9
  :root {
14
10
  --modern-sidebar-width: 0 !important;
@@ -37,6 +33,15 @@ footer.mt-8 {
37
33
  flex-direction: column;
38
34
  height: 100%;
39
35
  color: #000;
36
+ font-family:
37
+ PingFang SC,
38
+ Hiragino Sans GB,
39
+ Microsoft YaHei,
40
+ Arial,
41
+ sans-serif;
42
+ font-size: 14px;
43
+ border-top: 1px solid #CCCCCC;
44
+ border-bottom: 1px solid #CCCCCC;
40
45
  }
41
46
  .ant-layout {
42
47
  flex-grow: 1;
package/dist/es/index.js CHANGED
@@ -31,6 +31,7 @@ import { useExecutionDump } from "./component/store";
31
31
  import DetailSide from "./component/detail-side";
32
32
  import Sidebar from "./component/sidebar";
33
33
  const { Dragger } = Upload;
34
+ let globalRenderCount = 1;
34
35
  function Visualizer(props) {
35
36
  const { dump } = props;
36
37
  const executionDump = useExecutionDump((store) => store.dump);
@@ -151,6 +152,26 @@ function Visualizer(props) {
151
152
  }
152
153
  );
153
154
  }
155
+ const [containerHeight, setContainerHeight] = useState("100%");
156
+ useEffect(() => {
157
+ const ifInRspressPage = document.querySelector(".rspress-nav");
158
+ const navHeightKey = "--rp-nav-height";
159
+ const originalNavHeight = getComputedStyle(document.documentElement).getPropertyValue(navHeightKey);
160
+ if (ifInRspressPage) {
161
+ setContainerHeight("calc(100vh - 72px)");
162
+ document.documentElement.style.setProperty(navHeightKey, "42px");
163
+ }
164
+ return () => {
165
+ if (ifInRspressPage) {
166
+ document.documentElement.style.setProperty(navHeightKey, originalNavHeight);
167
+ }
168
+ };
169
+ }, []);
170
+ useEffect(() => {
171
+ return () => {
172
+ globalRenderCount += 1;
173
+ };
174
+ }, []);
154
175
  return /* @__PURE__ */ jsxs(
155
176
  ConfigProvider,
156
177
  {
@@ -166,7 +187,7 @@ function Visualizer(props) {
166
187
  },
167
188
  children: [
168
189
  /* @__PURE__ */ jsx(Helmet, { children: /* @__PURE__ */ jsx("title", { children: "MidScene.js - Visualization Tool" }) }),
169
- /* @__PURE__ */ jsx("div", { className: "page-container", children: mainContent }),
190
+ /* @__PURE__ */ jsx("div", { className: "page-container", style: { height: containerHeight }, children: mainContent }, `render-${globalRenderCount}`),
170
191
  /* @__PURE__ */ jsx(GlobalHoverPreview, {})
171
192
  ]
172
193
  }
@@ -105,7 +105,11 @@ const BlackBoard = () => {
105
105
  );
106
106
  return () => {
107
107
  console.log("will destroy");
108
- app == null ? void 0 : app.destroy(true, { children: true, texture: true });
108
+ try {
109
+ app.destroy(true, { children: true, texture: true });
110
+ } catch (e) {
111
+ console.warn("destroy failed", e);
112
+ }
109
113
  };
110
114
  }, [app, screenWidth, screenHeight]);
111
115
  (0, import_react.useEffect)(() => {
@@ -18,9 +18,10 @@
18
18
  line-height: 1.5;
19
19
  }
20
20
  .detail-side .meta-kv .meta .meta-key {
21
+ font-weight: bold;
21
22
  width: 100px;
22
23
  text-align: right;
23
- padding-right: 10px;
24
+ padding-right: 16px;
24
25
  }
25
26
  .detail-side .meta-kv .meta .meta-value {
26
27
  flex: 1 1;
@@ -166,19 +166,19 @@ const DetailSide = () => {
166
166
  const metaKVElement = MetaKV({
167
167
  data: [
168
168
  {
169
- key: "Status",
169
+ key: "status",
170
170
  content: (task == null ? void 0 : task.status) || ""
171
171
  },
172
172
  {
173
- key: "Start",
173
+ key: "start",
174
174
  content: (0, import_utils.timeStr)((_a = task == null ? void 0 : task.timing) == null ? void 0 : _a.start)
175
175
  },
176
176
  {
177
- key: "End",
177
+ key: "end",
178
178
  content: (0, import_utils.timeStr)((_b = task == null ? void 0 : task.timing) == null ? void 0 : _b.end)
179
179
  },
180
180
  {
181
- key: "Time Cost",
181
+ key: "time cost",
182
182
  content: (0, import_misc.timeCostStrElement)((_c = task == null ? void 0 : task.timing) == null ? void 0 : _c.cost)
183
183
  }
184
184
  ]
@@ -30,11 +30,16 @@ const GlobalHoverPreview = () => {
30
30
  var _a;
31
31
  const wrapperRef = (0, import_react.useRef)(null);
32
32
  const hoverTask = (0, import_store.useExecutionDump)((store) => store.hoverTask);
33
+ const hoverTimestamp = (0, import_store.useExecutionDump)((store) => store.hoverTimestamp);
33
34
  const hoverPreviewConfig = (0, import_store.useExecutionDump)((store) => store.hoverPreviewConfig);
34
35
  const [imageW, setImageW] = (0, import_react.useState)(size);
35
36
  const [imageH, setImageH] = (0, import_react.useState)(size);
36
37
  const images = (_a = hoverTask == null ? void 0 : hoverTask.recorder) == null ? void 0 : _a.filter((item) => {
37
- return item.screenshot;
38
+ let valid = Boolean(item.screenshot);
39
+ if (hoverTimestamp) {
40
+ valid = valid && item.ts >= hoverTimestamp;
41
+ }
42
+ return valid;
38
43
  }).map((item) => item.screenshot);
39
44
  const { x, y } = hoverPreviewConfig || {};
40
45
  let left = 0;
@@ -57,6 +57,7 @@ const useExecutionDump = (0, import_zustand.create)((set, get) => {
57
57
  dump: null,
58
58
  activeTask: null,
59
59
  hoverTask: null,
60
+ hoverTimestamp: null,
60
61
  hoverPreviewConfig: null
61
62
  };
62
63
  const syncToInsightDump = (dump) => {
@@ -89,8 +90,8 @@ const useExecutionDump = (0, import_zustand.create)((set, get) => {
89
90
  resetInsightDump();
90
91
  }
91
92
  },
92
- setHoverTask(task) {
93
- set({ hoverTask: task });
93
+ setHoverTask(task, timestamp) {
94
+ set({ hoverTask: task, hoverTimestamp: timestamp || null });
94
95
  },
95
96
  setHoverPreviewConfig(config) {
96
97
  if (config) {
@@ -425,7 +425,7 @@ const Timeline = () => {
425
425
  const refBounding = (_a = wrapper.current) == null ? void 0 : _a.getBoundingClientRect();
426
426
  const task = idTaskMap[item.id];
427
427
  if (task) {
428
- setHoverTask(task);
428
+ setHoverTask(task, item.timeOffset + startingTime);
429
429
  setHoverPreviewConfig({
430
430
  x: mouseX + ((refBounding == null ? void 0 : refBounding.left) || 0),
431
431
  y: ((refBounding == null ? void 0 : refBounding.bottom) || 1) - 1
@@ -2,13 +2,9 @@ html,
2
2
  body {
3
3
  padding: 0;
4
4
  margin: 0;
5
- font-family:
6
- PingFang SC,
7
- Hiragino Sans GB,
8
- Microsoft YaHei,
9
- Arial,
10
- sans-serif;
11
- font-size: 14px;
5
+ }
6
+ .rspress-nav {
7
+ transition: 0.2s;
12
8
  }
13
9
  :root {
14
10
  --modern-sidebar-width: 0 !important;
@@ -37,6 +33,15 @@ footer.mt-8 {
37
33
  flex-direction: column;
38
34
  height: 100%;
39
35
  color: #000;
36
+ font-family:
37
+ PingFang SC,
38
+ Hiragino Sans GB,
39
+ Microsoft YaHei,
40
+ Arial,
41
+ sans-serif;
42
+ font-size: 14px;
43
+ border-top: 1px solid #CCCCCC;
44
+ border-bottom: 1px solid #CCCCCC;
40
45
  }
41
46
  .ant-layout {
42
47
  flex-grow: 1;
package/dist/lib/index.js CHANGED
@@ -63,6 +63,7 @@ var import_store = require("./component/store");
63
63
  var import_detail_side = __toESM(require("./component/detail-side"));
64
64
  var import_sidebar = __toESM(require("./component/sidebar"));
65
65
  const { Dragger } = import_antd.Upload;
66
+ let globalRenderCount = 1;
66
67
  function Visualizer(props) {
67
68
  const { dump } = props;
68
69
  const executionDump = (0, import_store.useExecutionDump)((store) => store.dump);
@@ -183,6 +184,26 @@ function Visualizer(props) {
183
184
  }
184
185
  );
185
186
  }
187
+ const [containerHeight, setContainerHeight] = (0, import_react.useState)("100%");
188
+ (0, import_react.useEffect)(() => {
189
+ const ifInRspressPage = document.querySelector(".rspress-nav");
190
+ const navHeightKey = "--rp-nav-height";
191
+ const originalNavHeight = getComputedStyle(document.documentElement).getPropertyValue(navHeightKey);
192
+ if (ifInRspressPage) {
193
+ setContainerHeight("calc(100vh - 72px)");
194
+ document.documentElement.style.setProperty(navHeightKey, "42px");
195
+ }
196
+ return () => {
197
+ if (ifInRspressPage) {
198
+ document.documentElement.style.setProperty(navHeightKey, originalNavHeight);
199
+ }
200
+ };
201
+ }, []);
202
+ (0, import_react.useEffect)(() => {
203
+ return () => {
204
+ globalRenderCount += 1;
205
+ };
206
+ }, []);
186
207
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
187
208
  import_antd.ConfigProvider,
188
209
  {
@@ -198,7 +219,7 @@ function Visualizer(props) {
198
219
  },
199
220
  children: [
200
221
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_head.Helmet, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: "MidScene.js - Visualization Tool" }) }),
201
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "page-container", children: mainContent }),
222
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "page-container", style: { height: containerHeight }, children: mainContent }, `render-${globalRenderCount}`),
202
223
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_global_hover_preview.default, {})
203
224
  ]
204
225
  }
@@ -11,7 +11,8 @@ export declare const useExecutionDump: import("zustand").UseBoundStore<import("z
11
11
  activeTask: ExecutionTask | null;
12
12
  setActiveTask: (task: ExecutionTask) => void;
13
13
  hoverTask: ExecutionTask | null;
14
- setHoverTask: (task: ExecutionTask | null) => void;
14
+ hoverTimestamp: number | null;
15
+ setHoverTask: (task: ExecutionTask | null, timestamp?: number | null) => void;
15
16
  hoverPreviewConfig: {
16
17
  x: number;
17
18
  y: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/visualizer",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "types": "./dist/types/index.d.ts",
5
5
  "jsnext:source": "./src/index.ts",
6
6
  "main": "./dist/lib/index.js",
@@ -19,7 +19,7 @@
19
19
  "react-dom": "~18.2.0",
20
20
  "react-resizable-panels": "2.0.22",
21
21
  "zustand": "4.5.2",
22
- "@midscene/core": "0.1.0"
22
+ "@midscene/core": "0.1.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@modern-js/module-tools": "^2.54.2",