@godscene/visualizer 1.7.11
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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/es/component/blackboard/highlights.mjs +47 -0
- package/dist/es/component/blackboard/index.css +118 -0
- package/dist/es/component/blackboard/index.mjs +122 -0
- package/dist/es/component/config-selector/index.mjs +251 -0
- package/dist/es/component/context-preview/index.mjs +37 -0
- package/dist/es/component/env-config/index.mjs +237 -0
- package/dist/es/component/env-config-reminder/index.css +30 -0
- package/dist/es/component/env-config-reminder/index.mjs +27 -0
- package/dist/es/component/form-field/index.mjs +158 -0
- package/dist/es/component/history-selector/index.css +237 -0
- package/dist/es/component/history-selector/index.mjs +197 -0
- package/dist/es/component/index.mjs +1 -0
- package/dist/es/component/logo/index.css +19 -0
- package/dist/es/component/logo/index.mjs +20 -0
- package/dist/es/component/logo/logo.mjs +2 -0
- package/dist/es/component/misc/index.mjs +96 -0
- package/dist/es/component/nav-actions/index.mjs +14 -0
- package/dist/es/component/nav-actions/style.css +35 -0
- package/dist/es/component/player/index.css +296 -0
- package/dist/es/component/player/index.mjs +702 -0
- package/dist/es/component/player/playback-controls.mjs +4 -0
- package/dist/es/component/player/report-download.mjs +61 -0
- package/dist/es/component/player/scenes/StepScene.mjs +194 -0
- package/dist/es/component/player/scenes/derive-frame-state.mjs +229 -0
- package/dist/es/component/player/scenes/export-branded-video.mjs +360 -0
- package/dist/es/component/player/scenes/frame-calculator.mjs +149 -0
- package/dist/es/component/player/scenes/playback-frame.mjs +6 -0
- package/dist/es/component/player/scenes/playback-layout.mjs +12 -0
- package/dist/es/component/player/scenes/pointer-layout.mjs +36 -0
- package/dist/es/component/player/use-frame-player.mjs +87 -0
- package/dist/es/component/playground/index.css +930 -0
- package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/es/component/playground-result/index.css +92 -0
- package/dist/es/component/playground-result/index.mjs +232 -0
- package/dist/es/component/prompt-input/index.css +832 -0
- package/dist/es/component/prompt-input/index.mjs +959 -0
- package/dist/es/component/screenshot-viewer/index.css +237 -0
- package/dist/es/component/screenshot-viewer/index.mjs +319 -0
- package/dist/es/component/service-mode-control/index.mjs +107 -0
- package/dist/es/component/shiny-text/index.css +107 -0
- package/dist/es/component/shiny-text/index.mjs +15 -0
- package/dist/es/component/universal-playground/empty-state.mjs +5 -0
- package/dist/es/component/universal-playground/index.css +619 -0
- package/dist/es/component/universal-playground/index.mjs +558 -0
- package/dist/es/component/universal-playground/providers/context-provider.mjs +90 -0
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +280 -0
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +279 -0
- package/dist/es/component/universal-playground/universal-playground-electron.mjs +668 -0
- package/dist/es/hooks/useMinimalTypeGate.mjs +47 -0
- package/dist/es/hooks/usePlaygroundExecution.mjs +435 -0
- package/dist/es/hooks/usePlaygroundState.mjs +278 -0
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +20 -0
- package/dist/es/hooks/useServerValid.mjs +55 -0
- package/dist/es/hooks/useTheme.mjs +25 -0
- package/dist/es/icons/action-chevron.mjs +61 -0
- package/dist/es/icons/avatar.mjs +70 -0
- package/dist/es/icons/close.mjs +61 -0
- package/dist/es/icons/global-perspective.mjs +58 -0
- package/dist/es/icons/history.mjs +72 -0
- package/dist/es/icons/magnifying-glass.mjs +81 -0
- package/dist/es/icons/player-setting.mjs +68 -0
- package/dist/es/icons/prompt-history.mjs +70 -0
- package/dist/es/icons/setting.mjs +62 -0
- package/dist/es/icons/show-marker.mjs +58 -0
- package/dist/es/index.mjs +26 -0
- package/dist/es/static/image/logo.png +0 -0
- package/dist/es/store/history.mjs +128 -0
- package/dist/es/store/store.mjs +277 -0
- package/dist/es/types.mjs +73 -0
- package/dist/es/utils/action-label.mjs +15 -0
- package/dist/es/utils/color.mjs +35 -0
- package/dist/es/utils/constants.mjs +99 -0
- package/dist/es/utils/device-capabilities.mjs +13 -0
- package/dist/es/utils/empty-state-scroll.mjs +8 -0
- package/dist/es/utils/highlight-element.mjs +62 -0
- package/dist/es/utils/index.mjs +13 -0
- package/dist/es/utils/playground-utils.mjs +43 -0
- package/dist/es/utils/progress-action-icon.mjs +30 -0
- package/dist/es/utils/prompt-input-utils.mjs +49 -0
- package/dist/es/utils/prompt-placeholder.mjs +19 -0
- package/dist/es/utils/replay-scripts.mjs +428 -0
- package/dist/lib/component/blackboard/highlights.js +84 -0
- package/dist/lib/component/blackboard/index.css +118 -0
- package/dist/lib/component/blackboard/index.js +169 -0
- package/dist/lib/component/config-selector/index.js +295 -0
- package/dist/lib/component/context-preview/index.js +82 -0
- package/dist/lib/component/env-config/index.js +271 -0
- package/dist/lib/component/env-config-reminder/index.css +30 -0
- package/dist/lib/component/env-config-reminder/index.js +61 -0
- package/dist/lib/component/form-field/index.js +204 -0
- package/dist/lib/component/history-selector/index.css +237 -0
- package/dist/lib/component/history-selector/index.js +243 -0
- package/dist/lib/component/index.js +58 -0
- package/dist/lib/component/logo/index.css +19 -0
- package/dist/lib/component/logo/index.js +67 -0
- package/dist/lib/component/logo/logo.js +24 -0
- package/dist/lib/component/misc/index.js +152 -0
- package/dist/lib/component/nav-actions/index.js +48 -0
- package/dist/lib/component/nav-actions/style.css +35 -0
- package/dist/lib/component/player/index.css +296 -0
- package/dist/lib/component/player/index.js +747 -0
- package/dist/lib/component/player/playback-controls.js +38 -0
- package/dist/lib/component/player/report-download.js +98 -0
- package/dist/lib/component/player/scenes/StepScene.js +228 -0
- package/dist/lib/component/player/scenes/derive-frame-state.js +266 -0
- package/dist/lib/component/player/scenes/export-branded-video.js +403 -0
- package/dist/lib/component/player/scenes/frame-calculator.js +186 -0
- package/dist/lib/component/player/scenes/playback-frame.js +40 -0
- package/dist/lib/component/player/scenes/playback-layout.js +46 -0
- package/dist/lib/component/player/scenes/pointer-layout.js +88 -0
- package/dist/lib/component/player/use-frame-player.js +121 -0
- package/dist/lib/component/playground/index.css +930 -0
- package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/lib/component/playground-result/index.css +92 -0
- package/dist/lib/component/playground-result/index.js +276 -0
- package/dist/lib/component/prompt-input/index.css +832 -0
- package/dist/lib/component/prompt-input/index.js +1005 -0
- package/dist/lib/component/screenshot-viewer/index.css +237 -0
- package/dist/lib/component/screenshot-viewer/index.js +353 -0
- package/dist/lib/component/service-mode-control/index.js +141 -0
- package/dist/lib/component/shiny-text/index.css +107 -0
- package/dist/lib/component/shiny-text/index.js +49 -0
- package/dist/lib/component/universal-playground/empty-state.js +39 -0
- package/dist/lib/component/universal-playground/index.css +619 -0
- package/dist/lib/component/universal-playground/index.js +607 -0
- package/dist/lib/component/universal-playground/providers/context-provider.js +133 -0
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +320 -0
- package/dist/lib/component/universal-playground/providers/storage-provider.js +337 -0
- package/dist/lib/component/universal-playground/universal-playground-electron.js +717 -0
- package/dist/lib/hooks/useMinimalTypeGate.js +81 -0
- package/dist/lib/hooks/usePlaygroundExecution.js +478 -0
- package/dist/lib/hooks/usePlaygroundState.js +312 -0
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +57 -0
- package/dist/lib/hooks/useServerValid.js +89 -0
- package/dist/lib/hooks/useTheme.js +59 -0
- package/dist/lib/icons/action-chevron.js +95 -0
- package/dist/lib/icons/avatar.js +104 -0
- package/dist/lib/icons/close.js +95 -0
- package/dist/lib/icons/global-perspective.js +92 -0
- package/dist/lib/icons/history.js +106 -0
- package/dist/lib/icons/magnifying-glass.js +115 -0
- package/dist/lib/icons/player-setting.js +102 -0
- package/dist/lib/icons/prompt-history.js +104 -0
- package/dist/lib/icons/setting.js +96 -0
- package/dist/lib/icons/show-marker.js +92 -0
- package/dist/lib/index.js +204 -0
- package/dist/lib/static/image/logo.png +0 -0
- package/dist/lib/store/history.js +135 -0
- package/dist/lib/store/store.js +287 -0
- package/dist/lib/types.js +119 -0
- package/dist/lib/utils/action-label.js +52 -0
- package/dist/lib/utils/color.js +75 -0
- package/dist/lib/utils/constants.js +172 -0
- package/dist/lib/utils/device-capabilities.js +50 -0
- package/dist/lib/utils/empty-state-scroll.js +42 -0
- package/dist/lib/utils/highlight-element.js +99 -0
- package/dist/lib/utils/index.js +69 -0
- package/dist/lib/utils/playground-utils.js +86 -0
- package/dist/lib/utils/progress-action-icon.js +67 -0
- package/dist/lib/utils/prompt-input-utils.js +89 -0
- package/dist/lib/utils/prompt-placeholder.js +53 -0
- package/dist/lib/utils/replay-scripts.js +474 -0
- package/dist/types/component/blackboard/highlights.d.ts +11 -0
- package/dist/types/component/blackboard/index.d.ts +10 -0
- package/dist/types/component/config-selector/index.d.ts +15 -0
- package/dist/types/component/context-preview/index.d.ts +9 -0
- package/dist/types/component/env-config/index.d.ts +8 -0
- package/dist/types/component/env-config-reminder/index.d.ts +6 -0
- package/dist/types/component/form-field/index.d.ts +17 -0
- package/dist/types/component/history-selector/index.d.ts +13 -0
- package/dist/types/component/index.d.ts +1 -0
- package/dist/types/component/logo/index.d.ts +5 -0
- package/dist/types/component/misc/index.d.ts +6 -0
- package/dist/types/component/nav-actions/index.d.ts +12 -0
- package/dist/types/component/player/index.d.ts +15 -0
- package/dist/types/component/player/playback-controls.d.ts +1 -0
- package/dist/types/component/player/report-download.d.ts +32 -0
- package/dist/types/component/player/scenes/StepScene.d.ts +9 -0
- package/dist/types/component/player/scenes/derive-frame-state.d.ts +40 -0
- package/dist/types/component/player/scenes/export-branded-video.d.ts +33 -0
- package/dist/types/component/player/scenes/frame-calculator.d.ts +40 -0
- package/dist/types/component/player/scenes/playback-frame.d.ts +3 -0
- package/dist/types/component/player/scenes/playback-layout.d.ts +7 -0
- package/dist/types/component/player/scenes/pointer-layout.d.ts +20 -0
- package/dist/types/component/player/use-frame-player.d.ts +17 -0
- package/dist/types/component/playground-result/index.d.ts +22 -0
- package/dist/types/component/prompt-input/index.d.ts +23 -0
- package/dist/types/component/screenshot-viewer/index.d.ts +23 -0
- package/dist/types/component/service-mode-control/index.d.ts +6 -0
- package/dist/types/component/shiny-text/index.d.ts +12 -0
- package/dist/types/component/universal-playground/empty-state.d.ts +3 -0
- package/dist/types/component/universal-playground/index.d.ts +4 -0
- package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
- package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
- package/dist/types/component/universal-playground/universal-playground-electron.d.ts +4 -0
- package/dist/types/hooks/useMinimalTypeGate.d.ts +72 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +40 -0
- package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
- package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
- package/dist/types/hooks/useServerValid.d.ts +1 -0
- package/dist/types/hooks/useTheme.d.ts +7 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/store/history.d.ts +16 -0
- package/dist/types/store/store.d.ts +57 -0
- package/dist/types/types.d.ts +278 -0
- package/dist/types/utils/action-label.d.ts +11 -0
- package/dist/types/utils/color.d.ts +4 -0
- package/dist/types/utils/constants.d.ts +80 -0
- package/dist/types/utils/device-capabilities.d.ts +9 -0
- package/dist/types/utils/empty-state-scroll.d.ts +11 -0
- package/dist/types/utils/highlight-element.d.ts +3 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/playground-utils.d.ts +11 -0
- package/dist/types/utils/progress-action-icon.d.ts +12 -0
- package/dist/types/utils/prompt-input-utils.d.ts +24 -0
- package/dist/types/utils/prompt-placeholder.d.ts +1 -0
- package/dist/types/utils/replay-scripts.d.ts +50 -0
- package/package.json +82 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) resolve(value);
|
|
10
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
11
|
+
}
|
|
12
|
+
function _async_to_generator(fn) {
|
|
13
|
+
return function() {
|
|
14
|
+
var self = this, args = arguments;
|
|
15
|
+
return new Promise(function(resolve, reject) {
|
|
16
|
+
var gen = fn.apply(self, args);
|
|
17
|
+
function _next(value) {
|
|
18
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
19
|
+
}
|
|
20
|
+
function _throw(err) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
22
|
+
}
|
|
23
|
+
_next(void 0);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const DEFAULT_REPORT_FILE_NAME = 'midscene_report.html';
|
|
28
|
+
function triggerReportDownload(options) {
|
|
29
|
+
return _async_to_generator(function*() {
|
|
30
|
+
const { content, defaultFileName = DEFAULT_REPORT_FILE_NAME, onDownloadReport, documentRef, urlRef, blobFactory, scheduleRevoke } = options;
|
|
31
|
+
if (onDownloadReport) return void (yield onDownloadReport({
|
|
32
|
+
content,
|
|
33
|
+
defaultFileName
|
|
34
|
+
}));
|
|
35
|
+
const activeDocument = null != documentRef ? documentRef : globalThis.document;
|
|
36
|
+
if (!activeDocument) throw new Error('Report download requires a document context.');
|
|
37
|
+
const activeUrl = null != urlRef ? urlRef : globalThis.URL;
|
|
38
|
+
if (!(null == activeUrl ? void 0 : activeUrl.createObjectURL) || !(null == activeUrl ? void 0 : activeUrl.revokeObjectURL)) throw new Error('Report download requires URL.createObjectURL support.');
|
|
39
|
+
const createBlob = null != blobFactory ? blobFactory : (parts, blobOptions)=>new Blob(parts, blobOptions);
|
|
40
|
+
const blob = createBlob([
|
|
41
|
+
content
|
|
42
|
+
], {
|
|
43
|
+
type: 'text/html'
|
|
44
|
+
});
|
|
45
|
+
const url = activeUrl.createObjectURL(blob);
|
|
46
|
+
const anchor = activeDocument.createElement('a');
|
|
47
|
+
anchor.href = url;
|
|
48
|
+
anchor.download = defaultFileName;
|
|
49
|
+
anchor.style.display = 'none';
|
|
50
|
+
activeDocument.body.appendChild(anchor);
|
|
51
|
+
try {
|
|
52
|
+
anchor.click();
|
|
53
|
+
} finally{
|
|
54
|
+
activeDocument.body.removeChild(anchor);
|
|
55
|
+
(null != scheduleRevoke ? scheduleRevoke : (callback)=>setTimeout(callback, 0))(()=>{
|
|
56
|
+
activeUrl.revokeObjectURL(url);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
})();
|
|
60
|
+
}
|
|
61
|
+
export { DEFAULT_REPORT_FILE_NAME, triggerReportDownload };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { mouseLoading } from "../../../utils/index.mjs";
|
|
4
|
+
import { getCenterHighlightBox } from "../../../utils/highlight-element.mjs";
|
|
5
|
+
import { deriveFrameState, shouldRenderCursor } from "./derive-frame-state.mjs";
|
|
6
|
+
import { getPlaybackViewport } from "./playback-layout.mjs";
|
|
7
|
+
import { resolvePointerLayout, resolveSpinnerLayout } from "./pointer-layout.mjs";
|
|
8
|
+
const POINTER_PHASE = 0.375;
|
|
9
|
+
const CROSSFADE_FRAMES = 10;
|
|
10
|
+
const StepsTimeline = ({ frameMap, autoZoom, frame, width: compWidth, height: compHeight, fps })=>{
|
|
11
|
+
const { scriptFrames, imageWidth: baseImgW, imageHeight: baseImgH } = frameMap;
|
|
12
|
+
const state = useMemo(()=>deriveFrameState(scriptFrames, frame, baseImgW, baseImgH, fps), [
|
|
13
|
+
scriptFrames,
|
|
14
|
+
frame,
|
|
15
|
+
baseImgW,
|
|
16
|
+
baseImgH,
|
|
17
|
+
fps
|
|
18
|
+
]);
|
|
19
|
+
if (!state.img) return null;
|
|
20
|
+
const { img, imageWidth: imgW, imageHeight: imgH, prevImg, camera, prevCamera, insights, spinning: spinningPointer, spinningElapsedMs, currentPointerImg, pointerVisible, title, subTitle, frameInScript, imageChanged, pointerMoved, rawProgress } = state;
|
|
21
|
+
const pT = autoZoom ? pointerMoved ? Math.min(rawProgress / POINTER_PHASE, 1) : rawProgress : 1;
|
|
22
|
+
const cT = pointerMoved ? rawProgress <= POINTER_PHASE ? 0 : Math.min((rawProgress - POINTER_PHASE) / (1 - POINTER_PHASE), 1) : rawProgress;
|
|
23
|
+
const pointerLeft = prevCamera.pointerLeft + (camera.pointerLeft - prevCamera.pointerLeft) * pT;
|
|
24
|
+
const pointerTop = prevCamera.pointerTop + (camera.pointerTop - prevCamera.pointerTop) * pT;
|
|
25
|
+
const cameraLeft = autoZoom ? prevCamera.left + (camera.left - prevCamera.left) * cT : 0;
|
|
26
|
+
const cameraTop = autoZoom ? prevCamera.top + (camera.top - prevCamera.top) * cT : 0;
|
|
27
|
+
const cameraWidth = autoZoom ? prevCamera.width + (camera.width - prevCamera.width) * cT : imgW;
|
|
28
|
+
const { offsetX, offsetY, contentWidth, contentHeight } = getPlaybackViewport(compWidth, compHeight, imgW, imgH);
|
|
29
|
+
const zoom = imgW / cameraWidth;
|
|
30
|
+
const tx = contentWidth / imgW * -cameraLeft;
|
|
31
|
+
const ty = contentHeight / imgH * -cameraTop;
|
|
32
|
+
const transformStyle = `scale(${zoom}) translate(${tx}px, ${ty}px)`;
|
|
33
|
+
const camH = imgH / imgW * cameraWidth;
|
|
34
|
+
const ptrX = (pointerLeft - cameraLeft) / cameraWidth * contentWidth;
|
|
35
|
+
const ptrY = (pointerTop - cameraTop) / camH * contentHeight;
|
|
36
|
+
const showCursor = shouldRenderCursor(pointerVisible, camera, prevCamera, imgW, imgH);
|
|
37
|
+
const pointerLayout = resolvePointerLayout(imgW);
|
|
38
|
+
const spinnerLayout = resolveSpinnerLayout(pointerLayout);
|
|
39
|
+
const resScale = pointerLayout.scale;
|
|
40
|
+
const crossfadeAlpha = imageChanged ? Math.min(frameInScript / CROSSFADE_FRAMES, 1) : 1;
|
|
41
|
+
const spinRotation = spinningPointer ? (Math.sin(spinningElapsedMs / 500 - Math.PI / 2) + 1) / 2 * Math.PI * 2 : 0;
|
|
42
|
+
const renderInsightOverlays = ()=>{
|
|
43
|
+
if (0 === insights.length) return null;
|
|
44
|
+
return insights.map((insight, idx)=>{
|
|
45
|
+
const overlays = [];
|
|
46
|
+
if (insight.highlightElement) {
|
|
47
|
+
const highlightBox = getCenterHighlightBox(insight.highlightElement);
|
|
48
|
+
overlays.push(/*#__PURE__*/ jsx("div", {
|
|
49
|
+
style: {
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
left: highlightBox.left,
|
|
52
|
+
top: highlightBox.top,
|
|
53
|
+
width: highlightBox.width,
|
|
54
|
+
height: highlightBox.height,
|
|
55
|
+
background: 'rgba(253, 89, 7, 0.4)',
|
|
56
|
+
border: `${2 * resScale}px solid #fd5907`,
|
|
57
|
+
boxShadow: `${2 * resScale}px ${2 * resScale}px ${+resScale}px rgba(51, 51, 51, 0.3)`,
|
|
58
|
+
opacity: insight.alpha,
|
|
59
|
+
pointerEvents: 'none'
|
|
60
|
+
}
|
|
61
|
+
}, `highlight-${idx}`));
|
|
62
|
+
}
|
|
63
|
+
if (insight.searchArea) {
|
|
64
|
+
const rect = insight.searchArea;
|
|
65
|
+
overlays.push(/*#__PURE__*/ jsx("div", {
|
|
66
|
+
style: {
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
left: rect.left,
|
|
69
|
+
top: rect.top,
|
|
70
|
+
width: rect.width,
|
|
71
|
+
height: rect.height,
|
|
72
|
+
background: 'rgba(2, 131, 145, 0.4)',
|
|
73
|
+
border: `${2 * resScale}px solid #028391`,
|
|
74
|
+
boxShadow: `${2 * resScale}px ${2 * resScale}px ${+resScale}px rgba(51, 51, 51, 0.3)`,
|
|
75
|
+
opacity: insight.alpha,
|
|
76
|
+
pointerEvents: 'none'
|
|
77
|
+
}
|
|
78
|
+
}, `search-${idx}`));
|
|
79
|
+
}
|
|
80
|
+
return overlays;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const renderContentArea = (w, h)=>/*#__PURE__*/ jsxs("div", {
|
|
84
|
+
style: {
|
|
85
|
+
width: w,
|
|
86
|
+
height: h,
|
|
87
|
+
position: 'relative',
|
|
88
|
+
overflow: 'hidden'
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
imageChanged && prevImg && crossfadeAlpha < 1 && /*#__PURE__*/ jsx("div", {
|
|
92
|
+
style: {
|
|
93
|
+
position: 'absolute',
|
|
94
|
+
width: w,
|
|
95
|
+
height: h,
|
|
96
|
+
overflow: 'hidden',
|
|
97
|
+
opacity: 1 - crossfadeAlpha
|
|
98
|
+
},
|
|
99
|
+
children: /*#__PURE__*/ jsx("img", {
|
|
100
|
+
alt: "",
|
|
101
|
+
src: prevImg,
|
|
102
|
+
style: {
|
|
103
|
+
width: w,
|
|
104
|
+
height: h,
|
|
105
|
+
transformOrigin: '0 0',
|
|
106
|
+
transform: transformStyle
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
}),
|
|
110
|
+
/*#__PURE__*/ jsxs("div", {
|
|
111
|
+
style: {
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
width: w,
|
|
114
|
+
height: h,
|
|
115
|
+
overflow: 'hidden',
|
|
116
|
+
opacity: imageChanged ? crossfadeAlpha : 1
|
|
117
|
+
},
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ jsx("img", {
|
|
120
|
+
alt: "",
|
|
121
|
+
src: img,
|
|
122
|
+
style: {
|
|
123
|
+
width: w,
|
|
124
|
+
height: h,
|
|
125
|
+
transformOrigin: '0 0',
|
|
126
|
+
transform: transformStyle
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ jsx("div", {
|
|
130
|
+
style: {
|
|
131
|
+
position: 'absolute',
|
|
132
|
+
top: 0,
|
|
133
|
+
left: 0,
|
|
134
|
+
width: w,
|
|
135
|
+
height: h,
|
|
136
|
+
transformOrigin: '0 0',
|
|
137
|
+
transform: transformStyle,
|
|
138
|
+
pointerEvents: 'none'
|
|
139
|
+
},
|
|
140
|
+
children: renderInsightOverlays()
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
}),
|
|
144
|
+
spinningPointer && /*#__PURE__*/ jsx("img", {
|
|
145
|
+
alt: "",
|
|
146
|
+
src: mouseLoading,
|
|
147
|
+
style: {
|
|
148
|
+
position: 'absolute',
|
|
149
|
+
left: ptrX - spinnerLayout.centerOffset,
|
|
150
|
+
top: ptrY - spinnerLayout.centerOffset,
|
|
151
|
+
width: spinnerLayout.size,
|
|
152
|
+
height: spinnerLayout.size,
|
|
153
|
+
transform: `rotate(${spinRotation}rad)`,
|
|
154
|
+
transformOrigin: 'center center',
|
|
155
|
+
filter: 'drop-shadow(0 1px 2px rgba(0,0,0,0.3))'
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
showCursor && !spinningPointer && /*#__PURE__*/ jsx("img", {
|
|
159
|
+
alt: "",
|
|
160
|
+
src: currentPointerImg,
|
|
161
|
+
style: {
|
|
162
|
+
position: 'absolute',
|
|
163
|
+
left: ptrX - pointerLayout.hotspotX,
|
|
164
|
+
top: ptrY - pointerLayout.hotspotY,
|
|
165
|
+
width: pointerLayout.width,
|
|
166
|
+
height: pointerLayout.height,
|
|
167
|
+
filter: 'drop-shadow(0 1px 2px rgba(0,0,0,0.3))'
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
return /*#__PURE__*/ jsx("div", {
|
|
173
|
+
style: {
|
|
174
|
+
position: 'absolute',
|
|
175
|
+
top: 0,
|
|
176
|
+
left: 0,
|
|
177
|
+
right: 0,
|
|
178
|
+
bottom: 0,
|
|
179
|
+
backgroundColor: '#000'
|
|
180
|
+
},
|
|
181
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
182
|
+
style: {
|
|
183
|
+
position: 'absolute',
|
|
184
|
+
left: offsetX,
|
|
185
|
+
top: offsetY,
|
|
186
|
+
width: contentWidth,
|
|
187
|
+
height: contentHeight,
|
|
188
|
+
overflow: 'hidden'
|
|
189
|
+
},
|
|
190
|
+
children: renderContentArea(contentWidth, contentHeight)
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
export { StepsTimeline };
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { mousePointer } from "../../../utils/index.mjs";
|
|
2
|
+
function _define_property(obj, key, value) {
|
|
3
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
else obj[key] = value;
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
function _object_spread(target) {
|
|
13
|
+
for(var i = 1; i < arguments.length; i++){
|
|
14
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
15
|
+
var ownKeys = Object.keys(source);
|
|
16
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
17
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
18
|
+
}));
|
|
19
|
+
ownKeys.forEach(function(key) {
|
|
20
|
+
_define_property(target, key, source[key]);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
function derive_frame_state_ownKeys(object, enumerableOnly) {
|
|
26
|
+
var keys = Object.keys(object);
|
|
27
|
+
if (Object.getOwnPropertySymbols) {
|
|
28
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
29
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
30
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
31
|
+
});
|
|
32
|
+
keys.push.apply(keys, symbols);
|
|
33
|
+
}
|
|
34
|
+
return keys;
|
|
35
|
+
}
|
|
36
|
+
function _object_spread_props(target, source) {
|
|
37
|
+
source = null != source ? source : {};
|
|
38
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
39
|
+
else derive_frame_state_ownKeys(Object(source)).forEach(function(key) {
|
|
40
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
41
|
+
});
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
function createDefaultCameraState(imageWidth, imageHeight) {
|
|
45
|
+
return {
|
|
46
|
+
left: 0,
|
|
47
|
+
top: 0,
|
|
48
|
+
width: imageWidth,
|
|
49
|
+
pointerLeft: Math.round(imageWidth / 2),
|
|
50
|
+
pointerTop: Math.round(imageHeight / 2)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function updateImage(acc, sf, baseW, baseH) {
|
|
54
|
+
if (!sf.img) return;
|
|
55
|
+
if (acc.img && sf.img !== acc.img) {
|
|
56
|
+
acc.prevImg = acc.img;
|
|
57
|
+
acc.imageChanged = true;
|
|
58
|
+
}
|
|
59
|
+
const nextImgW = sf.imageWidth || baseW;
|
|
60
|
+
const nextImgH = sf.imageHeight || baseH;
|
|
61
|
+
const dimensionsChanged = acc.imgW !== nextImgW || acc.imgH !== nextImgH;
|
|
62
|
+
acc.img = sf.img;
|
|
63
|
+
acc.imgW = nextImgW;
|
|
64
|
+
acc.imgH = nextImgH;
|
|
65
|
+
if (dimensionsChanged) {
|
|
66
|
+
const resetCamera = createDefaultCameraState(nextImgW, nextImgH);
|
|
67
|
+
acc.camera = _object_spread({}, resetCamera);
|
|
68
|
+
acc.prevCamera = _object_spread({}, resetCamera);
|
|
69
|
+
acc.pointerMoved = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function checkPointerMoved(prev, cur) {
|
|
73
|
+
return Math.abs(prev.pointerLeft - cur.pointerLeft) > 1 || Math.abs(prev.pointerTop - cur.pointerTop) > 1;
|
|
74
|
+
}
|
|
75
|
+
function shouldRenderCursor(pointerVisible, camera, prevCamera, imageWidth, imageHeight) {
|
|
76
|
+
const centerX = Math.round(imageWidth / 2);
|
|
77
|
+
const centerY = Math.round(imageHeight / 2);
|
|
78
|
+
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;
|
|
79
|
+
}
|
|
80
|
+
function handleImg(acc, sf, frame, baseW, baseH) {
|
|
81
|
+
updateImage(acc, sf, baseW, baseH);
|
|
82
|
+
const sfEnd = sf.startFrame + sf.durationInFrames;
|
|
83
|
+
if (sf.cameraTarget) {
|
|
84
|
+
acc.prevCamera = _object_spread({}, acc.camera);
|
|
85
|
+
acc.camera = _object_spread({}, sf.cameraTarget);
|
|
86
|
+
acc.pointerMoved = checkPointerMoved(acc.prevCamera, acc.camera);
|
|
87
|
+
} else if (frame >= sfEnd) {
|
|
88
|
+
acc.pointerMoved = false;
|
|
89
|
+
acc.imageChanged = false;
|
|
90
|
+
}
|
|
91
|
+
acc.spinning = false;
|
|
92
|
+
}
|
|
93
|
+
function handleInsight(acc, sf, frame, baseW, baseH) {
|
|
94
|
+
updateImage(acc, sf, baseW, baseH);
|
|
95
|
+
const alreadyAdded = acc.insights.some((ai)=>ai.highlightElement === sf.highlightElement && ai.searchArea === sf.searchArea);
|
|
96
|
+
if (!alreadyAdded) acc.insights.push({
|
|
97
|
+
highlightElement: sf.highlightElement,
|
|
98
|
+
searchArea: sf.searchArea,
|
|
99
|
+
alpha: 1
|
|
100
|
+
});
|
|
101
|
+
if (sf.cameraTarget && void 0 !== sf.insightPhaseFrames) {
|
|
102
|
+
const cameraStartFrame = sf.startFrame + sf.insightPhaseFrames;
|
|
103
|
+
if (frame >= cameraStartFrame) {
|
|
104
|
+
acc.prevCamera = _object_spread({}, acc.camera);
|
|
105
|
+
acc.camera = _object_spread({}, sf.cameraTarget);
|
|
106
|
+
const cameraFrameIn = frame - cameraStartFrame;
|
|
107
|
+
const cameraDur = sf.cameraPhaseFrames || 1;
|
|
108
|
+
acc.rawProgress = Math.min(cameraFrameIn / cameraDur, 1);
|
|
109
|
+
acc.pointerMoved = checkPointerMoved(acc.prevCamera, acc.camera);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
acc.spinning = false;
|
|
113
|
+
}
|
|
114
|
+
function handleClearInsight(acc, sf, frame) {
|
|
115
|
+
const sfEnd = sf.startFrame + sf.durationInFrames;
|
|
116
|
+
const alpha = 1 - acc.rawProgress;
|
|
117
|
+
acc.insights = acc.insights.map((ai)=>_object_spread_props(_object_spread({}, ai), {
|
|
118
|
+
alpha
|
|
119
|
+
}));
|
|
120
|
+
if (frame >= sfEnd) acc.insights = [];
|
|
121
|
+
acc.spinning = false;
|
|
122
|
+
}
|
|
123
|
+
function handleSpinningPointer(acc, fps) {
|
|
124
|
+
acc.spinning = true;
|
|
125
|
+
acc.spinningElapsedMs = acc.frameInScript / fps * 1000;
|
|
126
|
+
}
|
|
127
|
+
function deriveFrameState(scriptFrames, frame, baseW, baseH, fps) {
|
|
128
|
+
const defaultCamera = createDefaultCameraState(baseW, baseH);
|
|
129
|
+
const acc = {
|
|
130
|
+
img: '',
|
|
131
|
+
imgW: baseW,
|
|
132
|
+
imgH: baseH,
|
|
133
|
+
camera: _object_spread({}, defaultCamera),
|
|
134
|
+
prevCamera: _object_spread({}, defaultCamera),
|
|
135
|
+
prevImg: null,
|
|
136
|
+
insights: [],
|
|
137
|
+
spinning: false,
|
|
138
|
+
spinningElapsedMs: 0,
|
|
139
|
+
pointerImg: mousePointer,
|
|
140
|
+
pointerVisible: false,
|
|
141
|
+
title: '',
|
|
142
|
+
subTitle: '',
|
|
143
|
+
taskId: void 0,
|
|
144
|
+
frameInScript: 0,
|
|
145
|
+
scriptIndex: 0,
|
|
146
|
+
imageChanged: false,
|
|
147
|
+
pointerMoved: false,
|
|
148
|
+
rawProgress: 0
|
|
149
|
+
};
|
|
150
|
+
for(let i = 0; i < scriptFrames.length; i++){
|
|
151
|
+
var _sf_taskId;
|
|
152
|
+
const sf = scriptFrames[i];
|
|
153
|
+
const sfEnd = sf.startFrame + sf.durationInFrames;
|
|
154
|
+
if (0 === sf.durationInFrames) {
|
|
155
|
+
if (sf.startFrame <= frame) {
|
|
156
|
+
var _sf_taskId1;
|
|
157
|
+
if ('pointer' === sf.type && sf.pointerImg) {
|
|
158
|
+
acc.pointerImg = sf.pointerImg;
|
|
159
|
+
acc.pointerVisible = true;
|
|
160
|
+
}
|
|
161
|
+
acc.title = sf.title || acc.title;
|
|
162
|
+
acc.subTitle = sf.subTitle || acc.subTitle;
|
|
163
|
+
acc.taskId = null != (_sf_taskId1 = sf.taskId) ? _sf_taskId1 : acc.taskId;
|
|
164
|
+
acc.scriptIndex = i;
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (frame < sf.startFrame) break;
|
|
169
|
+
acc.title = sf.title || acc.title;
|
|
170
|
+
acc.subTitle = sf.subTitle || acc.subTitle;
|
|
171
|
+
acc.taskId = null != (_sf_taskId = sf.taskId) ? _sf_taskId : acc.taskId;
|
|
172
|
+
acc.scriptIndex = i;
|
|
173
|
+
acc.frameInScript = frame - sf.startFrame;
|
|
174
|
+
acc.rawProgress = Math.min(acc.frameInScript / sf.durationInFrames, 1);
|
|
175
|
+
switch(sf.type){
|
|
176
|
+
case 'img':
|
|
177
|
+
handleImg(acc, sf, frame, baseW, baseH);
|
|
178
|
+
break;
|
|
179
|
+
case 'insight':
|
|
180
|
+
handleInsight(acc, sf, frame, baseW, baseH);
|
|
181
|
+
break;
|
|
182
|
+
case 'clear-insight':
|
|
183
|
+
handleClearInsight(acc, sf, frame);
|
|
184
|
+
break;
|
|
185
|
+
case 'spinning-pointer':
|
|
186
|
+
handleSpinningPointer(acc, fps);
|
|
187
|
+
break;
|
|
188
|
+
case 'sleep':
|
|
189
|
+
acc.spinning = false;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
if (frame >= sfEnd) {
|
|
193
|
+
if ('clear-insight' !== sf.type) acc.imageChanged = false;
|
|
194
|
+
acc.pointerMoved = false;
|
|
195
|
+
acc.rawProgress = 1;
|
|
196
|
+
if (sf.cameraTarget) acc.prevCamera = _object_spread({}, acc.camera);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!acc.img) {
|
|
200
|
+
const firstImgScript = scriptFrames.find((sf)=>'img' === sf.type && sf.img);
|
|
201
|
+
if (firstImgScript) {
|
|
202
|
+
acc.img = firstImgScript.img;
|
|
203
|
+
acc.imgW = firstImgScript.imageWidth || baseW;
|
|
204
|
+
acc.imgH = firstImgScript.imageHeight || baseH;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
img: acc.img,
|
|
209
|
+
imageWidth: acc.imgW,
|
|
210
|
+
imageHeight: acc.imgH,
|
|
211
|
+
prevImg: acc.imageChanged ? acc.prevImg : null,
|
|
212
|
+
camera: acc.camera,
|
|
213
|
+
prevCamera: acc.prevCamera,
|
|
214
|
+
insights: acc.insights,
|
|
215
|
+
spinning: acc.spinning,
|
|
216
|
+
spinningElapsedMs: acc.spinningElapsedMs,
|
|
217
|
+
currentPointerImg: acc.pointerImg,
|
|
218
|
+
pointerVisible: acc.pointerVisible,
|
|
219
|
+
title: acc.title,
|
|
220
|
+
subTitle: acc.subTitle,
|
|
221
|
+
taskId: acc.taskId,
|
|
222
|
+
frameInScript: acc.frameInScript,
|
|
223
|
+
scriptIndex: acc.scriptIndex,
|
|
224
|
+
imageChanged: acc.imageChanged,
|
|
225
|
+
pointerMoved: acc.pointerMoved,
|
|
226
|
+
rawProgress: acc.rawProgress
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
export { deriveFrameState, shouldRenderCursor };
|