@midscene/visualizer 0.5.1 → 0.5.2-beta-20240929094445.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/dist/es/component/blackboard.css +1 -0
- package/dist/es/component/blackboard.js +11 -2
- package/dist/es/component/color.js +1 -1
- package/dist/es/component/detail-panel.js +2 -1
- package/dist/es/component/player-scripts.js +30 -9
- package/dist/es/component/player.js +13 -6
- package/dist/index.css +1 -0
- package/dist/index.js +1 -1
- package/dist/lib/component/blackboard.css +1 -0
- package/dist/lib/component/blackboard.js +11 -2
- package/dist/lib/component/color.js +1 -1
- package/dist/lib/component/detail-panel.js +2 -1
- package/dist/lib/component/player-scripts.js +32 -10
- package/dist/lib/component/player.js +13 -6
- package/dist/report/demo-mobile.html +2 -1
- package/dist/report/demo.html +1459 -4741
- package/dist/report/empty-error.html +2 -1
- package/dist/report/index.css +1 -0
- package/dist/report/index.html +2 -1
- package/dist/report/index.js +1 -1
- package/dist/report/multi.html +2 -1
- package/dist/types/component/player-scripts.d.ts +1 -0
- package/package.json +3 -2
|
@@ -25,10 +25,11 @@ import * as PIXI from "pixi.js";
|
|
|
25
25
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
26
26
|
import { colorForName, highlightColorForType } from "./color";
|
|
27
27
|
import "./blackboard.css";
|
|
28
|
+
import { DropShadowFilter } from "pixi-filters";
|
|
28
29
|
import { useBlackboardPreference, useInsightDump } from "./store";
|
|
29
30
|
const itemFillAlpha = 0.4;
|
|
30
|
-
const highlightAlpha = 0.
|
|
31
|
-
const bgOnAlpha =
|
|
31
|
+
const highlightAlpha = 0.4;
|
|
32
|
+
const bgOnAlpha = 1;
|
|
32
33
|
const bgOffAlpha = 0.3;
|
|
33
34
|
const noop = () => {
|
|
34
35
|
};
|
|
@@ -46,6 +47,14 @@ const rectMarkForItem = (rect, name, ifHighlight, onPointOver, onPointerOut) =>
|
|
|
46
47
|
graphics.on("pointerover", onPointOver);
|
|
47
48
|
graphics.on("pointerout", onPointerOut);
|
|
48
49
|
}
|
|
50
|
+
const dropShadowFilter = new DropShadowFilter({
|
|
51
|
+
blur: 2,
|
|
52
|
+
quality: 3,
|
|
53
|
+
alpha: 0.4,
|
|
54
|
+
offset: { x: 4, y: 4 },
|
|
55
|
+
color: 3355443
|
|
56
|
+
});
|
|
57
|
+
graphics.filters = [dropShadowFilter];
|
|
49
58
|
const nameFontSize = 18;
|
|
50
59
|
const texts = new PIXI.Text(name, {
|
|
51
60
|
fontSize: nameFontSize,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const sectionColor = ["#028391"];
|
|
2
2
|
const elementColor = ["#01204E"];
|
|
3
3
|
const highlightColorForSection = "#01204E";
|
|
4
|
-
const highlightColorForElement = "#
|
|
4
|
+
const highlightColorForElement = "#fd5907";
|
|
5
5
|
function djb2Hash(str) {
|
|
6
6
|
if (!str) {
|
|
7
7
|
str = "unnamed";
|
|
@@ -76,8 +76,9 @@ const DetailPanel = () => {
|
|
|
76
76
|
useEffect(() => {
|
|
77
77
|
const handleKeyDown = (e) => {
|
|
78
78
|
if (e.key === "Tab") {
|
|
79
|
+
const ifShift = e.shiftKey;
|
|
79
80
|
const index = availableViewTypes.indexOf(viewType);
|
|
80
|
-
const nextIndex = (index + 1) % availableViewTypes.length;
|
|
81
|
+
const nextIndex = ifShift ? (index - 1 + availableViewTypes.length) % availableViewTypes.length : (index + 1) % availableViewTypes.length;
|
|
81
82
|
setViewType(availableViewTypes[nextIndex]);
|
|
82
83
|
e.preventDefault();
|
|
83
84
|
}
|
|
@@ -33,8 +33,11 @@ const cameraStateForRect = (rect, imageWidth, imageHeight) => {
|
|
|
33
33
|
} else {
|
|
34
34
|
rectWidthOnPage = rect.height / imageHeight * imageWidth;
|
|
35
35
|
}
|
|
36
|
-
const cameraPaddingRatio = 0.
|
|
37
|
-
const cameraWidth =
|
|
36
|
+
const cameraPaddingRatio = rectWidthOnPage < 50 ? 0.3 : 0.2;
|
|
37
|
+
const cameraWidth = Math.min(
|
|
38
|
+
imageWidth,
|
|
39
|
+
rectWidthOnPage + imageWidth * cameraPaddingRatio * 2
|
|
40
|
+
);
|
|
38
41
|
const cameraHeight = cameraWidth * (imageHeight / imageWidth);
|
|
39
42
|
let left = Math.min(
|
|
40
43
|
rect.left - imageWidth * cameraPaddingRatio,
|
|
@@ -52,6 +55,20 @@ const cameraStateForRect = (rect, imageWidth, imageHeight) => {
|
|
|
52
55
|
width: cameraWidth
|
|
53
56
|
};
|
|
54
57
|
};
|
|
58
|
+
const mergeTwoCameraState = (cameraState1, cameraState2) => {
|
|
59
|
+
const newLeft = Math.min(cameraState1.left, cameraState2.left);
|
|
60
|
+
const newTop = Math.min(cameraState1.top, cameraState2.top);
|
|
61
|
+
const newRight = Math.max(
|
|
62
|
+
cameraState1.left + cameraState1.width,
|
|
63
|
+
cameraState2.left + cameraState2.width
|
|
64
|
+
);
|
|
65
|
+
const newWidth = newRight - newLeft;
|
|
66
|
+
return {
|
|
67
|
+
left: newLeft,
|
|
68
|
+
top: newTop,
|
|
69
|
+
width: newWidth
|
|
70
|
+
};
|
|
71
|
+
};
|
|
55
72
|
const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
56
73
|
if (!execution)
|
|
57
74
|
return null;
|
|
@@ -83,8 +100,10 @@ const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
|
83
100
|
}
|
|
84
101
|
const scripts = [];
|
|
85
102
|
let insightCameraState = void 0;
|
|
103
|
+
let currentCameraState = fullPageCameraState;
|
|
86
104
|
let insightOnTop = false;
|
|
87
|
-
execution.tasks.
|
|
105
|
+
const taskCount = execution.tasks.length;
|
|
106
|
+
execution.tasks.forEach((task, index) => {
|
|
88
107
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
89
108
|
if (task.type === "Planning") {
|
|
90
109
|
const planningTask = task;
|
|
@@ -120,7 +139,7 @@ const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
|
120
139
|
type: "insight",
|
|
121
140
|
img: insightDump.context.screenshotBase64,
|
|
122
141
|
insightDump,
|
|
123
|
-
camera: fullPageCameraState,
|
|
142
|
+
camera: currentCameraState === fullPageCameraState || !insightCameraState ? void 0 : mergeTwoCameraState(currentCameraState, insightCameraState),
|
|
124
143
|
duration: insightContentLength > 20 ? locateDuration : locateDuration * 0.5,
|
|
125
144
|
title,
|
|
126
145
|
subTitle
|
|
@@ -137,6 +156,7 @@ const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
|
137
156
|
const title = typeStr(task);
|
|
138
157
|
const subTitle = paramStr(task);
|
|
139
158
|
scripts.push(pointerScript(mousePointer, title, subTitle));
|
|
159
|
+
currentCameraState = insightCameraState != null ? insightCameraState : fullPageCameraState;
|
|
140
160
|
scripts.push({
|
|
141
161
|
type: "img",
|
|
142
162
|
img: (_g = (_f = task.recorder) == null ? void 0 : _f[0]) == null ? void 0 : _g.screenshot,
|
|
@@ -154,6 +174,7 @@ const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
|
154
174
|
});
|
|
155
175
|
insightOnTop = false;
|
|
156
176
|
}
|
|
177
|
+
const imgStillDuration = index < taskCount - 1 ? stillDuration : 0;
|
|
157
178
|
if ((_i = (_h = task.recorder) == null ? void 0 : _h[1]) == null ? void 0 : _i.screenshot) {
|
|
158
179
|
scripts.push({
|
|
159
180
|
type: "spinning-pointer",
|
|
@@ -165,15 +186,14 @@ const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
|
165
186
|
scripts.push({
|
|
166
187
|
type: "img",
|
|
167
188
|
img: (_k = (_j = task.recorder) == null ? void 0 : _j[1]) == null ? void 0 : _k.screenshot,
|
|
168
|
-
duration:
|
|
169
|
-
// camera: fullPageCameraState,
|
|
189
|
+
duration: imgStillDuration,
|
|
170
190
|
title,
|
|
171
191
|
subTitle
|
|
172
192
|
});
|
|
173
193
|
} else {
|
|
174
194
|
scripts.push({
|
|
175
195
|
type: "sleep",
|
|
176
|
-
duration:
|
|
196
|
+
duration: imgStillDuration,
|
|
177
197
|
title,
|
|
178
198
|
subTitle
|
|
179
199
|
});
|
|
@@ -182,7 +202,7 @@ const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
|
182
202
|
});
|
|
183
203
|
scripts.push({
|
|
184
204
|
type: "img",
|
|
185
|
-
duration: stillDuration,
|
|
205
|
+
duration: stillDuration * 0.5,
|
|
186
206
|
camera: fullPageCameraState
|
|
187
207
|
});
|
|
188
208
|
scripts.push({
|
|
@@ -193,5 +213,6 @@ const generateAnimationScripts = (execution, imageWidth, imageHeight) => {
|
|
|
193
213
|
};
|
|
194
214
|
export {
|
|
195
215
|
cameraStateForRect,
|
|
196
|
-
generateAnimationScripts
|
|
216
|
+
generateAnimationScripts,
|
|
217
|
+
mergeTwoCameraState
|
|
197
218
|
};
|
|
@@ -49,7 +49,7 @@ const cubicBezier = (t, p0, p1, p2, p3) => {
|
|
|
49
49
|
return p0 * t2 * t2 * t2 + 3 * p1 * t * t2 * t2 + 3 * p2 * t * t * t2 + p3 * t * t * t;
|
|
50
50
|
};
|
|
51
51
|
const cubicImage = (t) => {
|
|
52
|
-
return
|
|
52
|
+
return cubicBezier(t, 0, 0.69, 0.43, 1);
|
|
53
53
|
};
|
|
54
54
|
const cubicInsightElement = (t) => {
|
|
55
55
|
return cubicBezier(t, 0, 0.5, 0.5, 1);
|
|
@@ -243,8 +243,8 @@ const Player = () => {
|
|
|
243
243
|
const currentState = __spreadValues({}, cameraState.current);
|
|
244
244
|
const startLeft = currentState.left;
|
|
245
245
|
const startTop = currentState.top;
|
|
246
|
-
const startWidth = currentState.width;
|
|
247
246
|
const startPointer = __spreadValues({}, currentState.pointer);
|
|
247
|
+
const startScale = currentState.width / imageWidth;
|
|
248
248
|
const startTime = performance.now();
|
|
249
249
|
const shouldMovePointer = targetState.pointer && (targetState.pointer.left !== startPointer.left || targetState.pointer.top !== startPointer.top);
|
|
250
250
|
const pointerMoveDuration = shouldMovePointer ? duration * 0.375 : 0;
|
|
@@ -270,10 +270,17 @@ const Player = () => {
|
|
|
270
270
|
1
|
|
271
271
|
);
|
|
272
272
|
const cameraProgress = cubicImage(rawCameraProgress);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
273
|
+
const targetScale = targetState.width / imageWidth;
|
|
274
|
+
const progressScale = startScale + (targetScale - startScale) * cameraProgress;
|
|
275
|
+
const progressWidth = imageWidth * progressScale;
|
|
276
|
+
const progressHeight = imageHeight * progressScale;
|
|
277
|
+
nextState.width = progressWidth;
|
|
278
|
+
const progressLeft = startLeft + (targetState.left - startLeft) * cameraProgress;
|
|
279
|
+
const progressTop = startTop + (targetState.top - startTop) * cameraProgress;
|
|
280
|
+
const horizontalExceed = progressLeft + progressWidth - imageWidth;
|
|
281
|
+
const verticalExceed = progressTop + progressHeight - imageHeight;
|
|
282
|
+
nextState.left = horizontalExceed > 0 ? progressLeft + horizontalExceed : progressLeft;
|
|
283
|
+
nextState.top = verticalExceed > 0 ? progressTop + verticalExceed : progressTop;
|
|
277
284
|
}
|
|
278
285
|
updateCamera(nextState);
|
|
279
286
|
if (elapsedTime < duration) {
|