@midscene/visualizer 1.7.7-beta-20260429033400.0 → 1.7.7
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/index.css +27 -2
- package/dist/es/component/player/index.mjs +123 -50
- package/dist/es/component/player/playback-controls.mjs +4 -0
- package/dist/es/component/player/scenes/StepScene.mjs +16 -13
- package/dist/es/component/player/scenes/derive-frame-state.mjs +12 -2
- package/dist/es/component/player/scenes/export-branded-video.mjs +182 -47
- package/dist/es/component/player/scenes/pointer-layout.mjs +36 -0
- package/dist/lib/component/player/index.css +27 -2
- package/dist/lib/component/player/index.js +122 -49
- package/dist/lib/component/player/playback-controls.js +38 -0
- package/dist/lib/component/player/scenes/StepScene.js +15 -12
- package/dist/lib/component/player/scenes/derive-frame-state.js +16 -3
- package/dist/lib/component/player/scenes/export-branded-video.js +188 -47
- package/dist/lib/component/player/scenes/pointer-layout.js +88 -0
- package/dist/types/component/player/index.d.ts +1 -1
- package/dist/types/component/player/playback-controls.d.ts +1 -0
- package/dist/types/component/player/scenes/derive-frame-state.d.ts +2 -0
- package/dist/types/component/player/scenes/export-branded-video.d.ts +16 -0
- package/dist/types/component/player/scenes/pointer-layout.d.ts +20 -0
- package/package.json +5 -5
|
@@ -46,6 +46,7 @@ var global_perspective_js_default = /*#__PURE__*/ __webpack_require__.n(global_p
|
|
|
46
46
|
const player_setting_js_namespaceObject = require("../../icons/player-setting.js");
|
|
47
47
|
var player_setting_js_default = /*#__PURE__*/ __webpack_require__.n(player_setting_js_namespaceObject);
|
|
48
48
|
const store_js_namespaceObject = require("../../store/store.js");
|
|
49
|
+
const external_playback_controls_js_namespaceObject = require("./playback-controls.js");
|
|
49
50
|
const external_report_download_js_namespaceObject = require("./report-download.js");
|
|
50
51
|
const StepScene_js_namespaceObject = require("./scenes/StepScene.js");
|
|
51
52
|
const export_branded_video_js_namespaceObject = require("./scenes/export-branded-video.js");
|
|
@@ -150,20 +151,38 @@ function Player(props) {
|
|
|
150
151
|
loop: false,
|
|
151
152
|
playbackRate: playbackSpeed
|
|
152
153
|
});
|
|
154
|
+
const effectiveEndFrame = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
155
|
+
if (!frameMap) return 0;
|
|
156
|
+
for(let i = frameMap.scriptFrames.length - 1; i >= 0; i--){
|
|
157
|
+
const sf = frameMap.scriptFrames[i];
|
|
158
|
+
if (sf.taskId) return sf.startFrame + sf.durationInFrames - 1;
|
|
159
|
+
}
|
|
160
|
+
return Math.max(0, frameMap.totalDurationInFrames - 1);
|
|
161
|
+
}, [
|
|
162
|
+
frameMap
|
|
163
|
+
]);
|
|
164
|
+
const handlePlaybackToggle = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
165
|
+
if (player.playing) return void player.pause();
|
|
166
|
+
if ((0, external_playback_controls_js_namespaceObject.shouldRestartPlaybackFromBeginning)(player.currentFrame, effectiveEndFrame)) player.seekTo(0);
|
|
167
|
+
player.play();
|
|
168
|
+
}, [
|
|
169
|
+
effectiveEndFrame,
|
|
170
|
+
player.currentFrame,
|
|
171
|
+
player.pause,
|
|
172
|
+
player.play,
|
|
173
|
+
player.playing,
|
|
174
|
+
player.seekTo
|
|
175
|
+
]);
|
|
153
176
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
154
177
|
if (!frameMap || player.playing) return;
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
for(let i = scriptFrames.length - 1; i >= 0; i--){
|
|
158
|
-
const sf = scriptFrames[i];
|
|
159
|
-
if (sf.taskId) {
|
|
160
|
-
player.seekTo(sf.startFrame + sf.durationInFrames - 1);
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
178
|
+
if (player.currentFrame < frameMap.totalDurationInFrames - 1) return;
|
|
179
|
+
if (effectiveEndFrame > 0) player.seekTo(effectiveEndFrame);
|
|
164
180
|
}, [
|
|
181
|
+
effectiveEndFrame,
|
|
165
182
|
frameMap,
|
|
166
|
-
player.
|
|
183
|
+
player.currentFrame,
|
|
184
|
+
player.playing,
|
|
185
|
+
player.seekTo
|
|
167
186
|
]);
|
|
168
187
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
169
188
|
if (!frameMap || !(null == props ? void 0 : props.onTaskChange)) return;
|
|
@@ -217,21 +236,40 @@ function Player(props) {
|
|
|
217
236
|
}, [
|
|
218
237
|
currentFrameState
|
|
219
238
|
]);
|
|
239
|
+
const [isExporting, setIsExporting] = (0, external_react_namespaceObject.useState)(false);
|
|
240
|
+
const [exportProgress, setExportProgress] = (0, external_react_namespaceObject.useState)(0);
|
|
241
|
+
const exportInFlightRef = (0, external_react_namespaceObject.useRef)(false);
|
|
220
242
|
const [controlsVisible, setControlsVisible] = (0, external_react_namespaceObject.useState)(true);
|
|
221
243
|
const hideTimerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
222
244
|
const showControls = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
223
245
|
setControlsVisible(true);
|
|
224
246
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
247
|
+
if (isExporting) return;
|
|
225
248
|
hideTimerRef.current = setTimeout(()=>setControlsVisible(false), 3000);
|
|
226
|
-
}, [
|
|
249
|
+
}, [
|
|
250
|
+
isExporting
|
|
251
|
+
]);
|
|
227
252
|
const onMouseEnter = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
228
253
|
setControlsVisible(true);
|
|
229
254
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
230
255
|
}, []);
|
|
231
256
|
const onMouseLeave = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
232
257
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
258
|
+
if (isExporting) return;
|
|
233
259
|
hideTimerRef.current = setTimeout(()=>setControlsVisible(false), 1000);
|
|
234
|
-
}, [
|
|
260
|
+
}, [
|
|
261
|
+
isExporting
|
|
262
|
+
]);
|
|
263
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
264
|
+
if (!isExporting) return;
|
|
265
|
+
setControlsVisible(true);
|
|
266
|
+
if (hideTimerRef.current) {
|
|
267
|
+
clearTimeout(hideTimerRef.current);
|
|
268
|
+
hideTimerRef.current = null;
|
|
269
|
+
}
|
|
270
|
+
}, [
|
|
271
|
+
isExporting
|
|
272
|
+
]);
|
|
235
273
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
236
274
|
const handleKeyDown = (e)=>{
|
|
237
275
|
var _e_target;
|
|
@@ -239,13 +277,13 @@ function Player(props) {
|
|
|
239
277
|
if ('INPUT' === tag || 'TEXTAREA' === tag || 'SELECT' === tag) return;
|
|
240
278
|
if ('Space' === e.code) {
|
|
241
279
|
e.preventDefault();
|
|
242
|
-
|
|
280
|
+
handlePlaybackToggle();
|
|
243
281
|
}
|
|
244
282
|
};
|
|
245
283
|
document.addEventListener('keydown', handleKeyDown);
|
|
246
284
|
return ()=>document.removeEventListener('keydown', handleKeyDown);
|
|
247
285
|
}, [
|
|
248
|
-
|
|
286
|
+
handlePlaybackToggle
|
|
249
287
|
]);
|
|
250
288
|
const seekBarRef = (0, external_react_namespaceObject.useRef)(null);
|
|
251
289
|
const handleSeekPointerDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
@@ -255,7 +293,7 @@ function Player(props) {
|
|
|
255
293
|
const seek = (clientX)=>{
|
|
256
294
|
const rect = bar.getBoundingClientRect();
|
|
257
295
|
const ratio = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
258
|
-
player.seekTo(Math.round(ratio *
|
|
296
|
+
player.seekTo(Math.round(ratio * effectiveEndFrame));
|
|
259
297
|
};
|
|
260
298
|
seek(e.clientX);
|
|
261
299
|
const onMove = (ev)=>seek(ev.clientX);
|
|
@@ -267,7 +305,8 @@ function Player(props) {
|
|
|
267
305
|
bar.addEventListener('pointerup', onUp);
|
|
268
306
|
}, [
|
|
269
307
|
frameMap,
|
|
270
|
-
player
|
|
308
|
+
player,
|
|
309
|
+
effectiveEndFrame
|
|
271
310
|
]);
|
|
272
311
|
const [isFullscreen, setIsFullscreen] = (0, external_react_namespaceObject.useState)(false);
|
|
273
312
|
const toggleFullscreen = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
@@ -281,10 +320,9 @@ function Player(props) {
|
|
|
281
320
|
document.addEventListener('fullscreenchange', handler);
|
|
282
321
|
return ()=>document.removeEventListener('fullscreenchange', handler);
|
|
283
322
|
}, []);
|
|
284
|
-
const [isExporting, setIsExporting] = (0, external_react_namespaceObject.useState)(false);
|
|
285
|
-
const [exportProgress, setExportProgress] = (0, external_react_namespaceObject.useState)(0);
|
|
286
323
|
const handleExportVideo = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
287
|
-
if (!frameMap ||
|
|
324
|
+
if (!frameMap || exportInFlightRef.current) return;
|
|
325
|
+
exportInFlightRef.current = true;
|
|
288
326
|
setIsExporting(true);
|
|
289
327
|
setExportProgress(0);
|
|
290
328
|
try {
|
|
@@ -294,25 +332,24 @@ function Player(props) {
|
|
|
294
332
|
external_antd_namespaceObject.message.success('Video exported');
|
|
295
333
|
} catch (e) {
|
|
296
334
|
console.error('Export failed:', e);
|
|
297
|
-
|
|
335
|
+
const errorMessage = e instanceof Error ? e.message : 'Export failed';
|
|
336
|
+
external_antd_namespaceObject.message.error(errorMessage);
|
|
298
337
|
} finally{
|
|
338
|
+
exportInFlightRef.current = false;
|
|
299
339
|
setIsExporting(false);
|
|
300
340
|
setExportProgress(0);
|
|
301
341
|
}
|
|
302
342
|
})(), [
|
|
303
343
|
autoZoom,
|
|
304
|
-
frameMap
|
|
305
|
-
isExporting
|
|
344
|
+
frameMap
|
|
306
345
|
]);
|
|
307
346
|
const chapterMarkers = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
308
|
-
if (!frameMap) return [];
|
|
309
|
-
const { scriptFrames, totalDurationInFrames } = frameMap;
|
|
310
|
-
if (0 === totalDurationInFrames) return [];
|
|
347
|
+
if (!frameMap || effectiveEndFrame <= 0) return [];
|
|
311
348
|
const markers = [];
|
|
312
|
-
for (const sf of scriptFrames){
|
|
349
|
+
for (const sf of frameMap.scriptFrames){
|
|
313
350
|
if ('img' !== sf.type && 'insight' !== sf.type || 0 === sf.durationInFrames) continue;
|
|
314
351
|
const globalFrame = sf.startFrame;
|
|
315
|
-
const percent = globalFrame /
|
|
352
|
+
const percent = globalFrame / effectiveEndFrame * 100;
|
|
316
353
|
if (percent > 1 && percent < 99) {
|
|
317
354
|
const parts = [
|
|
318
355
|
sf.title,
|
|
@@ -327,16 +364,38 @@ function Player(props) {
|
|
|
327
364
|
}
|
|
328
365
|
return markers;
|
|
329
366
|
}, [
|
|
330
|
-
frameMap
|
|
367
|
+
frameMap,
|
|
368
|
+
effectiveEndFrame
|
|
331
369
|
]);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
370
|
+
var _props_reportFileContent;
|
|
371
|
+
const reportFileContent = null != (_props_reportFileContent = null == props ? void 0 : props.reportFileContent) ? _props_reportFileContent : null;
|
|
372
|
+
const canDownloadReport = (null == props ? void 0 : props.canDownloadReport) !== false;
|
|
373
|
+
if (!scripts || 0 === scripts.length || !frameMap) {
|
|
374
|
+
if (reportFileContent && canDownloadReport) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
375
|
+
className: "player-container player-container-empty",
|
|
376
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
377
|
+
className: "player-empty-state",
|
|
378
|
+
children: [
|
|
379
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
380
|
+
className: "player-empty-text",
|
|
381
|
+
children: "No replay available"
|
|
382
|
+
}),
|
|
383
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
|
|
384
|
+
icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.DownloadOutlined, {}),
|
|
385
|
+
onClick: ()=>{
|
|
386
|
+
handleDownloadReport();
|
|
387
|
+
},
|
|
388
|
+
children: "Download report"
|
|
389
|
+
})
|
|
390
|
+
]
|
|
391
|
+
})
|
|
392
|
+
});
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
335
395
|
const compositionWidth = (null == currentFrameState ? void 0 : currentFrameState.imageWidth) || frameMap.imageWidth;
|
|
336
396
|
const compositionHeight = (null == currentFrameState ? void 0 : currentFrameState.imageHeight) || frameMap.imageHeight;
|
|
337
397
|
const isPortraitCanvas = compositionHeight > compositionWidth;
|
|
338
|
-
const
|
|
339
|
-
const seekPercent = totalFrames > 1 ? player.currentFrame / (totalFrames - 1) * 100 : 0;
|
|
398
|
+
const seekPercent = effectiveEndFrame > 0 ? Math.min(100, player.currentFrame / effectiveEndFrame * 100) : 0;
|
|
340
399
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
341
400
|
className: "player-container",
|
|
342
401
|
"data-fit-mode": null == props ? void 0 : props.fitMode,
|
|
@@ -363,7 +422,7 @@ function Player(props) {
|
|
|
363
422
|
height: '100%',
|
|
364
423
|
overflow: 'hidden'
|
|
365
424
|
},
|
|
366
|
-
onClick:
|
|
425
|
+
onClick: handlePlaybackToggle,
|
|
367
426
|
children: (()=>{
|
|
368
427
|
const scale = containerSize.width > 0 && containerSize.height > 0 ? Math.min(containerSize.width / compositionWidth, containerSize.height / compositionHeight) : 1;
|
|
369
428
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
@@ -413,16 +472,16 @@ function Player(props) {
|
|
|
413
472
|
children: [
|
|
414
473
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
415
474
|
className: "status-icon",
|
|
416
|
-
onClick:
|
|
475
|
+
onClick: handlePlaybackToggle,
|
|
417
476
|
children: player.playing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.PauseOutlined, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.CaretRightOutlined, {})
|
|
418
477
|
}),
|
|
419
478
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
420
479
|
className: "time-display",
|
|
421
480
|
children: [
|
|
422
|
-
formatTime(player.currentFrame, frameMap.fps),
|
|
423
|
-
" /",
|
|
481
|
+
formatTime(Math.min(player.currentFrame, effectiveEndFrame), frameMap.fps),
|
|
424
482
|
' ',
|
|
425
|
-
|
|
483
|
+
"/ ",
|
|
484
|
+
formatTime(effectiveEndFrame + 1, frameMap.fps)
|
|
426
485
|
]
|
|
427
486
|
}),
|
|
428
487
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
@@ -461,7 +520,7 @@ function Player(props) {
|
|
|
461
520
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
462
521
|
className: "player-custom-controls",
|
|
463
522
|
children: [
|
|
464
|
-
|
|
523
|
+
reportFileContent && canDownloadReport ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
465
524
|
title: "Download Report",
|
|
466
525
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
467
526
|
className: "status-icon",
|
|
@@ -497,18 +556,32 @@ function Player(props) {
|
|
|
497
556
|
},
|
|
498
557
|
onClick: isExporting ? void 0 : handleExportVideo,
|
|
499
558
|
children: [
|
|
500
|
-
isExporting ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
501
|
-
size: "small"
|
|
502
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.ExportOutlined, {
|
|
503
|
-
style: {
|
|
504
|
-
width: '16px',
|
|
505
|
-
height: '16px'
|
|
506
|
-
}
|
|
507
|
-
}),
|
|
508
559
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
509
560
|
style: {
|
|
510
|
-
|
|
561
|
+
width: 16,
|
|
562
|
+
height: 16,
|
|
563
|
+
display: 'inline-flex',
|
|
564
|
+
alignItems: 'center',
|
|
565
|
+
justifyContent: 'center',
|
|
566
|
+
flexShrink: 0
|
|
511
567
|
},
|
|
568
|
+
children: isExporting ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Progress, {
|
|
569
|
+
type: "circle",
|
|
570
|
+
percent: exportProgress,
|
|
571
|
+
size: 16,
|
|
572
|
+
strokeWidth: 14,
|
|
573
|
+
showInfo: false,
|
|
574
|
+
strokeColor: "#1677ff",
|
|
575
|
+
trailColor: "rgba(0, 0, 0, 0.12)"
|
|
576
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.ExportOutlined, {
|
|
577
|
+
style: {
|
|
578
|
+
width: '16px',
|
|
579
|
+
height: '16px'
|
|
580
|
+
}
|
|
581
|
+
})
|
|
582
|
+
}),
|
|
583
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
584
|
+
className: "player-export-label",
|
|
512
585
|
children: isExporting ? `Exporting ${exportProgress}%` : 'Export video'
|
|
513
586
|
})
|
|
514
587
|
]
|
|
@@ -632,7 +705,7 @@ function Player(props) {
|
|
|
632
705
|
style: {
|
|
633
706
|
height: '32px',
|
|
634
707
|
lineHeight: '32px',
|
|
635
|
-
padding: '0 8px 0
|
|
708
|
+
padding: '0 8px 0 28px',
|
|
636
709
|
fontSize: '14px',
|
|
637
710
|
cursor: 'pointer',
|
|
638
711
|
borderRadius: '4px'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
shouldRestartPlaybackFromBeginning: ()=>shouldRestartPlaybackFromBeginning
|
|
28
|
+
});
|
|
29
|
+
function shouldRestartPlaybackFromBeginning(currentFrame, effectiveEndFrame) {
|
|
30
|
+
return effectiveEndFrame > 0 && currentFrame >= effectiveEndFrame;
|
|
31
|
+
}
|
|
32
|
+
exports.shouldRestartPlaybackFromBeginning = __webpack_exports__.shouldRestartPlaybackFromBeginning;
|
|
33
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
34
|
+
"shouldRestartPlaybackFromBeginning"
|
|
35
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
36
|
+
Object.defineProperty(exports, '__esModule', {
|
|
37
|
+
value: true
|
|
38
|
+
});
|
|
@@ -32,6 +32,7 @@ const index_js_namespaceObject = require("../../../utils/index.js");
|
|
|
32
32
|
const highlight_element_js_namespaceObject = require("../../../utils/highlight-element.js");
|
|
33
33
|
const external_derive_frame_state_js_namespaceObject = require("./derive-frame-state.js");
|
|
34
34
|
const external_playback_layout_js_namespaceObject = require("./playback-layout.js");
|
|
35
|
+
const external_pointer_layout_js_namespaceObject = require("./pointer-layout.js");
|
|
35
36
|
const POINTER_PHASE = 0.375;
|
|
36
37
|
const CROSSFADE_FRAMES = 10;
|
|
37
38
|
const StepsTimeline = ({ frameMap, autoZoom, frame, width: compWidth, height: compHeight, fps })=>{
|
|
@@ -44,8 +45,8 @@ const StepsTimeline = ({ frameMap, autoZoom, frame, width: compWidth, height: co
|
|
|
44
45
|
fps
|
|
45
46
|
]);
|
|
46
47
|
if (!state.img) return null;
|
|
47
|
-
const { img, imageWidth: imgW, imageHeight: imgH, prevImg, camera, prevCamera, insights, spinning: spinningPointer, spinningElapsedMs, currentPointerImg, title, subTitle, frameInScript, imageChanged, pointerMoved, rawProgress } = state;
|
|
48
|
-
const pT = pointerMoved ? Math.min(rawProgress / POINTER_PHASE, 1) : rawProgress;
|
|
48
|
+
const { img, imageWidth: imgW, imageHeight: imgH, prevImg, camera, prevCamera, insights, spinning: spinningPointer, spinningElapsedMs, currentPointerImg, pointerVisible, title, subTitle, frameInScript, imageChanged, pointerMoved, rawProgress } = state;
|
|
49
|
+
const pT = autoZoom ? pointerMoved ? Math.min(rawProgress / POINTER_PHASE, 1) : rawProgress : 1;
|
|
49
50
|
const cT = pointerMoved ? rawProgress <= POINTER_PHASE ? 0 : Math.min((rawProgress - POINTER_PHASE) / (1 - POINTER_PHASE), 1) : rawProgress;
|
|
50
51
|
const pointerLeft = prevCamera.pointerLeft + (camera.pointerLeft - prevCamera.pointerLeft) * pT;
|
|
51
52
|
const pointerTop = prevCamera.pointerTop + (camera.pointerTop - prevCamera.pointerTop) * pT;
|
|
@@ -60,8 +61,10 @@ const StepsTimeline = ({ frameMap, autoZoom, frame, width: compWidth, height: co
|
|
|
60
61
|
const camH = imgH / imgW * cameraWidth;
|
|
61
62
|
const ptrX = (pointerLeft - cameraLeft) / cameraWidth * contentWidth;
|
|
62
63
|
const ptrY = (pointerTop - cameraTop) / camH * contentHeight;
|
|
63
|
-
const showCursor =
|
|
64
|
-
const
|
|
64
|
+
const showCursor = (0, external_derive_frame_state_js_namespaceObject.shouldRenderCursor)(pointerVisible, camera, prevCamera, imgW, imgH);
|
|
65
|
+
const pointerLayout = (0, external_pointer_layout_js_namespaceObject.resolvePointerLayout)(imgW);
|
|
66
|
+
const spinnerLayout = (0, external_pointer_layout_js_namespaceObject.resolveSpinnerLayout)(pointerLayout);
|
|
67
|
+
const resScale = pointerLayout.scale;
|
|
65
68
|
const crossfadeAlpha = imageChanged ? Math.min(frameInScript / CROSSFADE_FRAMES, 1) : 1;
|
|
66
69
|
const spinRotation = spinningPointer ? (Math.sin(spinningElapsedMs / 500 - Math.PI / 2) + 1) / 2 * Math.PI * 2 : 0;
|
|
67
70
|
const renderInsightOverlays = ()=>{
|
|
@@ -171,10 +174,10 @@ const StepsTimeline = ({ frameMap, autoZoom, frame, width: compWidth, height: co
|
|
|
171
174
|
src: index_js_namespaceObject.mouseLoading,
|
|
172
175
|
style: {
|
|
173
176
|
position: 'absolute',
|
|
174
|
-
left: ptrX -
|
|
175
|
-
top: ptrY -
|
|
176
|
-
width:
|
|
177
|
-
height:
|
|
177
|
+
left: ptrX - spinnerLayout.centerOffset,
|
|
178
|
+
top: ptrY - spinnerLayout.centerOffset,
|
|
179
|
+
width: spinnerLayout.size,
|
|
180
|
+
height: spinnerLayout.size,
|
|
178
181
|
transform: `rotate(${spinRotation}rad)`,
|
|
179
182
|
transformOrigin: 'center center',
|
|
180
183
|
filter: 'drop-shadow(0 1px 2px rgba(0,0,0,0.3))'
|
|
@@ -185,10 +188,10 @@ const StepsTimeline = ({ frameMap, autoZoom, frame, width: compWidth, height: co
|
|
|
185
188
|
src: currentPointerImg,
|
|
186
189
|
style: {
|
|
187
190
|
position: 'absolute',
|
|
188
|
-
left: ptrX -
|
|
189
|
-
top: ptrY -
|
|
190
|
-
width:
|
|
191
|
-
height:
|
|
191
|
+
left: ptrX - pointerLayout.hotspotX,
|
|
192
|
+
top: ptrY - pointerLayout.hotspotY,
|
|
193
|
+
width: pointerLayout.width,
|
|
194
|
+
height: pointerLayout.height,
|
|
192
195
|
filter: 'drop-shadow(0 1px 2px rgba(0,0,0,0.3))'
|
|
193
196
|
}
|
|
194
197
|
})
|
|
@@ -24,7 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
deriveFrameState: ()=>deriveFrameState
|
|
27
|
+
deriveFrameState: ()=>deriveFrameState,
|
|
28
|
+
shouldRenderCursor: ()=>shouldRenderCursor
|
|
28
29
|
});
|
|
29
30
|
const index_js_namespaceObject = require("../../../utils/index.js");
|
|
30
31
|
function _define_property(obj, key, value) {
|
|
@@ -100,6 +101,11 @@ function updateImage(acc, sf, baseW, baseH) {
|
|
|
100
101
|
function checkPointerMoved(prev, cur) {
|
|
101
102
|
return Math.abs(prev.pointerLeft - cur.pointerLeft) > 1 || Math.abs(prev.pointerTop - cur.pointerTop) > 1;
|
|
102
103
|
}
|
|
104
|
+
function shouldRenderCursor(pointerVisible, camera, prevCamera, imageWidth, imageHeight) {
|
|
105
|
+
const centerX = Math.round(imageWidth / 2);
|
|
106
|
+
const centerY = Math.round(imageHeight / 2);
|
|
107
|
+
return pointerVisible || Math.abs(camera.pointerLeft - centerX) > 1 || Math.abs(camera.pointerTop - centerY) > 1 || Math.abs(prevCamera.pointerLeft - centerX) > 1 || Math.abs(prevCamera.pointerTop - centerY) > 1;
|
|
108
|
+
}
|
|
103
109
|
function handleImg(acc, sf, frame, baseW, baseH) {
|
|
104
110
|
updateImage(acc, sf, baseW, baseH);
|
|
105
111
|
const sfEnd = sf.startFrame + sf.durationInFrames;
|
|
@@ -160,6 +166,7 @@ function deriveFrameState(scriptFrames, frame, baseW, baseH, fps) {
|
|
|
160
166
|
spinning: false,
|
|
161
167
|
spinningElapsedMs: 0,
|
|
162
168
|
pointerImg: index_js_namespaceObject.mousePointer,
|
|
169
|
+
pointerVisible: false,
|
|
163
170
|
title: '',
|
|
164
171
|
subTitle: '',
|
|
165
172
|
taskId: void 0,
|
|
@@ -174,7 +181,10 @@ function deriveFrameState(scriptFrames, frame, baseW, baseH, fps) {
|
|
|
174
181
|
const sfEnd = sf.startFrame + sf.durationInFrames;
|
|
175
182
|
if (0 === sf.durationInFrames) {
|
|
176
183
|
if (sf.startFrame <= frame) {
|
|
177
|
-
if ('pointer' === sf.type && sf.pointerImg)
|
|
184
|
+
if ('pointer' === sf.type && sf.pointerImg) {
|
|
185
|
+
acc.pointerImg = sf.pointerImg;
|
|
186
|
+
acc.pointerVisible = true;
|
|
187
|
+
}
|
|
178
188
|
acc.title = sf.title || acc.title;
|
|
179
189
|
acc.subTitle = sf.subTitle || acc.subTitle;
|
|
180
190
|
var _sf_taskId;
|
|
@@ -234,6 +244,7 @@ function deriveFrameState(scriptFrames, frame, baseW, baseH, fps) {
|
|
|
234
244
|
spinning: acc.spinning,
|
|
235
245
|
spinningElapsedMs: acc.spinningElapsedMs,
|
|
236
246
|
currentPointerImg: acc.pointerImg,
|
|
247
|
+
pointerVisible: acc.pointerVisible,
|
|
237
248
|
title: acc.title,
|
|
238
249
|
subTitle: acc.subTitle,
|
|
239
250
|
taskId: acc.taskId,
|
|
@@ -245,8 +256,10 @@ function deriveFrameState(scriptFrames, frame, baseW, baseH, fps) {
|
|
|
245
256
|
};
|
|
246
257
|
}
|
|
247
258
|
exports.deriveFrameState = __webpack_exports__.deriveFrameState;
|
|
259
|
+
exports.shouldRenderCursor = __webpack_exports__.shouldRenderCursor;
|
|
248
260
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
249
|
-
"deriveFrameState"
|
|
261
|
+
"deriveFrameState",
|
|
262
|
+
"shouldRenderCursor"
|
|
250
263
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
251
264
|
Object.defineProperty(exports, '__esModule', {
|
|
252
265
|
value: true
|