@midscene/visualizer 0.5.2-beta-20241010035503.0 → 0.5.2
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/player.js +15 -3
- package/dist/es/component/replay-scripts.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/component/player.js +15 -3
- package/dist/lib/component/replay-scripts.js +1 -1
- package/dist/report/demo-mobile.html +1 -1
- package/dist/report/demo.html +1 -1
- package/dist/report/empty-error.html +1 -1
- package/dist/report/index.html +1 -1
- package/dist/report/index.js +1 -1
- package/dist/report/multi.html +1 -1
- package/package.json +2 -2
|
@@ -111,6 +111,17 @@ const frameKit = () => {
|
|
|
111
111
|
callback(performance.now());
|
|
112
112
|
});
|
|
113
113
|
},
|
|
114
|
+
timeout: (callback, ms) => {
|
|
115
|
+
if (cancelFlag) {
|
|
116
|
+
throw new Error(ERROR_FRAME_CANCEL);
|
|
117
|
+
}
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
if (cancelFlag) {
|
|
120
|
+
throw new Error(ERROR_FRAME_CANCEL);
|
|
121
|
+
}
|
|
122
|
+
callback();
|
|
123
|
+
}, ms);
|
|
124
|
+
},
|
|
114
125
|
cancel: () => {
|
|
115
126
|
console.log("set frame cancel");
|
|
116
127
|
cancelFlag = true;
|
|
@@ -448,7 +459,7 @@ const Player = () => {
|
|
|
448
459
|
if (!scripts) {
|
|
449
460
|
throw new Error("scripts is required");
|
|
450
461
|
}
|
|
451
|
-
const { frame, cancel } = frameKit();
|
|
462
|
+
const { frame, cancel, timeout } = frameKit();
|
|
452
463
|
cancelFn = cancel;
|
|
453
464
|
const allImages = scripts.filter((item) => !!item.img).map((item) => item.img);
|
|
454
465
|
yield Promise.all([...allImages, import_utils.mouseLoading].map(preloadImage));
|
|
@@ -459,6 +470,7 @@ const Player = () => {
|
|
|
459
470
|
const totalDuration = scripts.reduce((acc, item) => {
|
|
460
471
|
return acc + item.duration + (item.insightCameraDuration || 0);
|
|
461
472
|
}, 0);
|
|
473
|
+
const progressUpdateInterval = 300;
|
|
462
474
|
const startTime = performance.now();
|
|
463
475
|
setAnimationProgress(0);
|
|
464
476
|
const updateProgress = () => {
|
|
@@ -467,7 +479,7 @@ const Player = () => {
|
|
|
467
479
|
1
|
|
468
480
|
);
|
|
469
481
|
setAnimationProgress(progress);
|
|
470
|
-
return
|
|
482
|
+
return timeout(updateProgress, progressUpdateInterval);
|
|
471
483
|
};
|
|
472
484
|
frame(updateProgress);
|
|
473
485
|
for (const index in scripts) {
|
|
@@ -537,7 +549,7 @@ const Player = () => {
|
|
|
537
549
|
Promise.resolve(
|
|
538
550
|
(() => __async(void 0, null, function* () {
|
|
539
551
|
yield init();
|
|
540
|
-
|
|
552
|
+
setReplayMark(Date.now());
|
|
541
553
|
}))()
|
|
542
554
|
);
|
|
543
555
|
return () => {
|
|
@@ -56,7 +56,7 @@ const cameraStateForRect = (rect, imageWidth, imageHeight) => {
|
|
|
56
56
|
} else {
|
|
57
57
|
rectWidthOnPage = rect.height / imageHeight * imageWidth;
|
|
58
58
|
}
|
|
59
|
-
const cameraPaddingRatio = rectWidthOnPage
|
|
59
|
+
const cameraPaddingRatio = rectWidthOnPage > 400 ? 0.1 : rectWidthOnPage > 50 ? 0.2 : 0.3;
|
|
60
60
|
const cameraWidth = Math.min(
|
|
61
61
|
imageWidth,
|
|
62
62
|
rectWidthOnPage + imageWidth * cameraPaddingRatio * 2
|