@midscene/visualizer 0.1.4 → 0.2.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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -21
  3. package/dist/es/component/blackboard.js +32 -8
  4. package/dist/es/component/color.js +2 -4
  5. package/dist/es/component/detail-panel.js +28 -14
  6. package/dist/es/component/detail-side.css +1 -1
  7. package/dist/es/component/detail-side.js +99 -28
  8. package/dist/es/component/global-hover-preview.css +2 -2
  9. package/dist/es/component/global-hover-preview.js +25 -12
  10. package/dist/es/component/panel-title.css +3 -3
  11. package/dist/es/component/sidebar.css +7 -12
  12. package/dist/es/component/sidebar.js +31 -19
  13. package/dist/es/component/store.js +8 -2
  14. package/dist/es/component/timeline.css +1 -1
  15. package/dist/es/component/timeline.js +52 -19
  16. package/dist/es/demo-dump.json +1 -0
  17. package/dist/es/index.css +13 -9
  18. package/dist/es/index.js +44 -26
  19. package/dist/es/utils.js +9 -10
  20. package/dist/lib/component/blackboard.js +31 -7
  21. package/dist/lib/component/color.js +2 -4
  22. package/dist/lib/component/detail-panel.js +23 -13
  23. package/dist/lib/component/detail-side.css +1 -1
  24. package/dist/lib/component/detail-side.js +98 -27
  25. package/dist/lib/component/global-hover-preview.css +2 -2
  26. package/dist/lib/component/global-hover-preview.js +26 -13
  27. package/dist/lib/component/panel-title.css +3 -3
  28. package/dist/lib/component/sidebar.css +7 -12
  29. package/dist/lib/component/sidebar.js +31 -19
  30. package/dist/lib/component/store.js +8 -2
  31. package/dist/lib/component/timeline.css +1 -1
  32. package/dist/lib/component/timeline.js +52 -19
  33. package/dist/lib/demo-dump.json +1 -0
  34. package/dist/lib/index.css +13 -9
  35. package/dist/lib/index.js +43 -25
  36. package/dist/lib/utils.js +9 -10
  37. package/dist/types/component/store.d.ts +1 -1
  38. package/dist/types/index.d.ts +1 -1
  39. package/dist/types/utils.d.ts +1 -1
  40. package/package.json +9 -9
@@ -1,6 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import "./sidebar.css";
3
- import { useEffect } from "react";
3
+ import { useAllCurrentTasks, useExecutionDump } from "./store";
4
+ import { typeStr } from "../utils";
4
5
  import {
5
6
  ArrowRightOutlined,
6
7
  CheckOutlined,
@@ -10,11 +11,10 @@ import {
10
11
  MinusOutlined
11
12
  } from "@ant-design/icons";
12
13
  import { Button } from "antd";
13
- import PanelTitle from "./panel-title";
14
- import { timeCostStrElement } from "./misc";
14
+ import { useEffect } from "react";
15
15
  import Logo from "./assets/logo-plain2.js";
16
- import { useAllCurrentTasks, useExecutionDump } from "./store";
17
- import { typeStr } from "../utils";
16
+ import { timeCostStrElement } from "./misc";
17
+ import PanelTitle from "./panel-title";
18
18
  const SideItem = (props) => {
19
19
  var _a, _b, _c;
20
20
  const { task, onClick, selected } = props;
@@ -62,7 +62,7 @@ const SideItem = (props) => {
62
62
  },
63
63
  children: [
64
64
  " ",
65
- /* @__PURE__ */ jsxs("div", { className: `side-item-name`, children: [
65
+ /* @__PURE__ */ jsxs("div", { className: "side-item-name", children: [
66
66
  /* @__PURE__ */ jsx("span", { className: `status-icon status-icon-${task.status}`, children: statusIcon }),
67
67
  /* @__PURE__ */ jsx("div", { className: "title", children: typeStr(task) }),
68
68
  /* @__PURE__ */ jsx("div", { className: "status-text", children: statusText })
@@ -77,10 +77,14 @@ const Sidebar = (props) => {
77
77
  const setActiveTask = useExecutionDump((store) => store.setActiveTask);
78
78
  const activeTask = useExecutionDump((store) => store.activeTask);
79
79
  const setHoverTask = useExecutionDump((store) => store.setHoverTask);
80
- const setHoverPreviewConfig = useExecutionDump((store) => store.setHoverPreviewConfig);
80
+ const setHoverPreviewConfig = useExecutionDump(
81
+ (store) => store.setHoverPreviewConfig
82
+ );
81
83
  const reset = useExecutionDump((store) => store.reset);
82
84
  const allTasks = useAllCurrentTasks();
83
- const currentSelectedIndex = allTasks == null ? void 0 : allTasks.findIndex((task) => task === activeTask);
85
+ const currentSelectedIndex = allTasks == null ? void 0 : allTasks.findIndex(
86
+ (task) => task === activeTask
87
+ );
84
88
  useEffect(() => {
85
89
  const handleKeyDown = (e) => {
86
90
  if (!(allTasks == null ? void 0 : allTasks.length) || (allTasks == null ? void 0 : allTasks.length) <= 1) {
@@ -156,22 +160,30 @@ const Sidebar = (props) => {
156
160
  }) : /* @__PURE__ */ jsx("span", { children: "no tasks" });
157
161
  return /* @__PURE__ */ jsxs("div", { className: "side-bar", children: [
158
162
  /* @__PURE__ */ jsxs("div", { className: "top-controls", children: [
159
- /* @__PURE__ */ jsx("div", { className: "brand", onClick: reset, style: { display: (props == null ? void 0 : props.hideLogo) ? "none" : "flex" }, children: /* @__PURE__ */ jsx(
160
- Logo,
163
+ /* @__PURE__ */ jsx(
164
+ "div",
161
165
  {
162
- style: { width: 70, height: 70, margin: "auto" },
163
- onClick: () => {
164
- if (props.logoAction) {
165
- props.logoAction();
166
- } else {
167
- location.reload();
166
+ className: "brand",
167
+ onClick: reset,
168
+ style: { display: (props == null ? void 0 : props.hideLogo) ? "none" : "flex" },
169
+ children: /* @__PURE__ */ jsx(
170
+ Logo,
171
+ {
172
+ style: { width: 70, height: 70, margin: "auto" },
173
+ onClick: () => {
174
+ if (props.logoAction) {
175
+ props.logoAction();
176
+ } else {
177
+ location.reload();
178
+ }
179
+ }
168
180
  }
169
- }
181
+ )
170
182
  }
171
- ) }),
183
+ ),
172
184
  /* @__PURE__ */ jsx("div", { className: "task-list", children: sideList }),
173
185
  /* @__PURE__ */ jsx("div", { className: "side-seperator side-seperator-line side-seperator-space-up" }),
174
- /* @__PURE__ */ jsx("div", { className: "task-meta-section", children: /* @__PURE__ */ jsx("div", { className: "task-meta", children: "use Command + ⬆︎ / ⬇︎ to switch" }) })
186
+ /* @__PURE__ */ jsx("div", { className: "task-meta-section", children: /* @__PURE__ */ jsx("div", { className: "task-meta", children: "switch: Command + Up / Down" }) })
175
187
  ] }),
176
188
  /* @__PURE__ */ jsx("div", { className: "bottom-controls", children: /* @__PURE__ */ jsx(Button, { onClick: reset, type: "text", className: "unload_btn", children: "Unload" }) })
177
189
  ] });
@@ -58,10 +58,11 @@ const useExecutionDump = create((set, get) => {
58
58
  }
59
59
  },
60
60
  setActiveTask(task) {
61
+ var _a;
61
62
  set({ activeTask: task });
62
63
  console.log("task set", task);
63
64
  if (task.type === "Insight") {
64
- syncToInsightDump(task.log.dump);
65
+ syncToInsightDump((_a = task.log) == null ? void 0 : _a.dump);
65
66
  } else {
66
67
  resetInsightDump();
67
68
  }
@@ -100,7 +101,12 @@ const useAllCurrentTasks = () => {
100
101
  };
101
102
  const useInsightDump = create((set) => {
102
103
  let loadId = 0;
103
- const initData = { _loadId: 0, highlightSectionNames: [], highlightElements: [], data: null };
104
+ const initData = {
105
+ _loadId: 0,
106
+ highlightSectionNames: [],
107
+ highlightElements: [],
108
+ data: null
109
+ };
104
110
  return __spreadProps(__spreadValues({}, initData), {
105
111
  loadData: (data) => {
106
112
  set({
@@ -4,7 +4,7 @@
4
4
  flex-shrink: 0;
5
5
  width: 100%;
6
6
  height: 100%;
7
- border-bottom: 1px solid #CCCCCC;
7
+ border-bottom: 1px solid #E5E5E5;
8
8
  position: relative;
9
9
  box-sizing: border-box;
10
10
  }
@@ -38,8 +38,8 @@ var __async = (__this, __arguments, generator) => {
38
38
  });
39
39
  };
40
40
  import { jsx } from "react/jsx-runtime";
41
- import { useEffect, useMemo, useRef } from "react";
42
41
  import * as PIXI from "pixi.js";
42
+ import { useEffect, useMemo, useRef } from "react";
43
43
  import "./timeline.css";
44
44
  import { useAllCurrentTasks, useExecutionDump } from "./store";
45
45
  function cloneSprite(sprite) {
@@ -67,17 +67,18 @@ const TimelineWidget = (props) => {
67
67
  const allScreenshots = props.screenshots || [];
68
68
  const maxTime = allScreenshots[allScreenshots.length - 1].timeOffset;
69
69
  const sizeRatio = 2;
70
- const titleBg = 14540253;
71
- const sideBg = 16250871;
70
+ const titleBg = 16316664;
71
+ const sideBg = 16777215;
72
72
  const gridTextColor = 0;
73
73
  const shotBorderColor = 7829367;
74
- const gridLineColor = 13421772;
75
- const gridHighlightColor = 438699;
74
+ const gridLineColor = 15066597;
75
+ const gridHighlightColor = 12567770;
76
+ const highlightMaskAlpha = 0.6;
76
77
  const timeContentFontSize = 20;
77
78
  const commonPadding = 12;
78
79
  const timeTextTop = commonPadding;
79
80
  const timeTitleBottom = timeTextTop * 2 + timeContentFontSize;
80
- const highlightMaskAlpha = 0.6;
81
+ const hoverMaskColor = 14474460;
81
82
  const hoverMaskAlpha = 0.3;
82
83
  const closestScreenshotItemOnXY = (x, _y) => {
83
84
  let closestScreenshot;
@@ -182,6 +183,11 @@ const TimelineWidget = (props) => {
182
183
  titleBgSection.drawRect(0, 0, canvasWidth, timeTitleBottom);
183
184
  titleBgSection.endFill();
184
185
  gridsContainer.addChild(titleBgSection);
186
+ const titleBottomBorder = new PIXI.Graphics();
187
+ titleBottomBorder.beginFill(gridLineColor);
188
+ titleBottomBorder.drawRect(0, timeTitleBottom, canvasWidth, sizeRatio);
189
+ titleBottomBorder.endFill();
190
+ gridsContainer.addChild(titleBottomBorder);
185
191
  const gridHeight = canvasHeight;
186
192
  for (let i = 1; i <= gridCount; i++) {
187
193
  const gridLine = new PIXI.Graphics();
@@ -217,7 +223,9 @@ const TimelineWidget = (props) => {
217
223
  const originalWidth = img.width;
218
224
  const originalHeight = img.height;
219
225
  const screenshotHeight = screenshotMaxHeight;
220
- const screenshotWidth = Math.floor(screenshotHeight / originalHeight * originalWidth);
226
+ const screenshotWidth = Math.floor(
227
+ screenshotHeight / originalHeight * originalWidth
228
+ );
221
229
  const screenshotX = leftForTimeOffset(screenshot.timeOffset);
222
230
  allScreenshots[index].x = screenshotX;
223
231
  allScreenshots[index].y = screenshotTop;
@@ -225,7 +233,12 @@ const TimelineWidget = (props) => {
225
233
  allScreenshots[index].height = screenshotMaxHeight;
226
234
  const border = new PIXI.Graphics();
227
235
  border.lineStyle(sizeRatio, shotBorderColor, 1);
228
- border.drawRect(screenshotX, screenshotTop, screenshotWidth, screenshotMaxHeight);
236
+ border.drawRect(
237
+ screenshotX,
238
+ screenshotTop,
239
+ screenshotWidth,
240
+ screenshotMaxHeight
241
+ );
229
242
  border.endFill();
230
243
  container.addChild(border);
231
244
  screenshotSprite.x = screenshotX;
@@ -237,18 +250,28 @@ const TimelineWidget = (props) => {
237
250
  });
238
251
  const highlightMaskUpdater = (start, end, hoverStart, hoverEnd) => {
239
252
  highlightMaskContainer.removeChildren();
240
- const mask = (start2, end2, alpha) => {
253
+ const mask = (start2, end2, color, alpha) => {
241
254
  if (typeof start2 === "undefined" || typeof end2 === "undefined" || end2 === 0) {
242
255
  return;
243
256
  }
244
257
  const leftBorder = new PIXI.Graphics();
245
258
  leftBorder.beginFill(gridHighlightColor, 1);
246
- leftBorder.drawRect(leftForTimeOffset(start2), 0, sizeRatio, canvasHeight);
259
+ leftBorder.drawRect(
260
+ leftForTimeOffset(start2),
261
+ 0,
262
+ sizeRatio,
263
+ canvasHeight
264
+ );
247
265
  leftBorder.endFill();
248
266
  highlightMaskContainer.addChild(leftBorder);
249
267
  const rightBorder = new PIXI.Graphics();
250
268
  rightBorder.beginFill(gridHighlightColor, 1);
251
- rightBorder.drawRect(leftForTimeOffset(end2), 0, sizeRatio, canvasHeight);
269
+ rightBorder.drawRect(
270
+ leftForTimeOffset(end2),
271
+ 0,
272
+ sizeRatio,
273
+ canvasHeight
274
+ );
252
275
  rightBorder.endFill();
253
276
  highlightMaskContainer.addChild(rightBorder);
254
277
  const mask2 = new PIXI.Graphics();
@@ -262,10 +285,15 @@ const TimelineWidget = (props) => {
262
285
  mask2.endFill();
263
286
  highlightMaskContainer.addChild(mask2);
264
287
  };
265
- mask(start, end, highlightMaskAlpha);
266
- mask(hoverStart, hoverEnd, hoverMaskAlpha);
288
+ mask(start, end, gridHighlightColor, highlightMaskAlpha);
289
+ mask(hoverStart, hoverEnd, hoverMaskColor, hoverMaskAlpha);
267
290
  };
268
- highlightMaskUpdater((_a2 = props.highlightMask) == null ? void 0 : _a2.startMs, (_b2 = props.highlightMask) == null ? void 0 : _b2.endMs, 0, 0);
291
+ highlightMaskUpdater(
292
+ (_a2 = props.highlightMask) == null ? void 0 : _a2.startMs,
293
+ (_b2 = props.highlightMask) == null ? void 0 : _b2.endMs,
294
+ 0,
295
+ 0
296
+ );
269
297
  containerUpdaterRef.current = highlightMaskUpdater;
270
298
  app.stage.interactive = true;
271
299
  const onPointerMove = (event) => {
@@ -273,7 +301,10 @@ const TimelineWidget = (props) => {
273
301
  const x = event.offsetX * sizeRatio;
274
302
  const y = event.offsetY * sizeRatio;
275
303
  indicatorContainer.removeChildren();
276
- const { closestScreenshot, closestIndex } = closestScreenshotItemOnXY(x, y);
304
+ const { closestScreenshot, closestIndex } = closestScreenshotItemOnXY(
305
+ x,
306
+ y
307
+ );
277
308
  if (closestIndex < 0) {
278
309
  (_a3 = props.onUnhighlight) == null ? void 0 : _a3.call(props);
279
310
  return;
@@ -286,9 +317,9 @@ const TimelineWidget = (props) => {
286
317
  newSpirit.drawRect(
287
318
  x,
288
319
  // follow mouse
289
- closestScreenshot.y,
290
- closestScreenshot.width,
291
- closestScreenshot.height
320
+ closestScreenshot == null ? void 0 : closestScreenshot.y,
321
+ closestScreenshot == null ? void 0 : closestScreenshot.width,
322
+ closestScreenshot == null ? void 0 : closestScreenshot.height
292
323
  );
293
324
  newSpirit.endFill();
294
325
  indicatorContainer.addChild(newSpirit);
@@ -350,7 +381,9 @@ const Timeline = () => {
350
381
  const activeTask = useExecutionDump((store) => store.activeTask);
351
382
  const hoverTask = useExecutionDump((store) => store.hoverTask);
352
383
  const setHoverTask = useExecutionDump((store) => store.setHoverTask);
353
- const setHoverPreviewConfig = useExecutionDump((store) => store.setHoverPreviewConfig);
384
+ const setHoverPreviewConfig = useExecutionDump(
385
+ (store) => store.setHoverPreviewConfig
386
+ );
354
387
  let startingTime = -1;
355
388
  let idCount = 1;
356
389
  const idTaskMap = {};