@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.
Files changed (221) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/es/component/blackboard/highlights.mjs +47 -0
  4. package/dist/es/component/blackboard/index.css +118 -0
  5. package/dist/es/component/blackboard/index.mjs +122 -0
  6. package/dist/es/component/config-selector/index.mjs +251 -0
  7. package/dist/es/component/context-preview/index.mjs +37 -0
  8. package/dist/es/component/env-config/index.mjs +237 -0
  9. package/dist/es/component/env-config-reminder/index.css +30 -0
  10. package/dist/es/component/env-config-reminder/index.mjs +27 -0
  11. package/dist/es/component/form-field/index.mjs +158 -0
  12. package/dist/es/component/history-selector/index.css +237 -0
  13. package/dist/es/component/history-selector/index.mjs +197 -0
  14. package/dist/es/component/index.mjs +1 -0
  15. package/dist/es/component/logo/index.css +19 -0
  16. package/dist/es/component/logo/index.mjs +20 -0
  17. package/dist/es/component/logo/logo.mjs +2 -0
  18. package/dist/es/component/misc/index.mjs +96 -0
  19. package/dist/es/component/nav-actions/index.mjs +14 -0
  20. package/dist/es/component/nav-actions/style.css +35 -0
  21. package/dist/es/component/player/index.css +296 -0
  22. package/dist/es/component/player/index.mjs +702 -0
  23. package/dist/es/component/player/playback-controls.mjs +4 -0
  24. package/dist/es/component/player/report-download.mjs +61 -0
  25. package/dist/es/component/player/scenes/StepScene.mjs +194 -0
  26. package/dist/es/component/player/scenes/derive-frame-state.mjs +229 -0
  27. package/dist/es/component/player/scenes/export-branded-video.mjs +360 -0
  28. package/dist/es/component/player/scenes/frame-calculator.mjs +149 -0
  29. package/dist/es/component/player/scenes/playback-frame.mjs +6 -0
  30. package/dist/es/component/player/scenes/playback-layout.mjs +12 -0
  31. package/dist/es/component/player/scenes/pointer-layout.mjs +36 -0
  32. package/dist/es/component/player/use-frame-player.mjs +87 -0
  33. package/dist/es/component/playground/index.css +930 -0
  34. package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
  35. package/dist/es/component/playground-result/index.css +92 -0
  36. package/dist/es/component/playground-result/index.mjs +232 -0
  37. package/dist/es/component/prompt-input/index.css +832 -0
  38. package/dist/es/component/prompt-input/index.mjs +959 -0
  39. package/dist/es/component/screenshot-viewer/index.css +237 -0
  40. package/dist/es/component/screenshot-viewer/index.mjs +319 -0
  41. package/dist/es/component/service-mode-control/index.mjs +107 -0
  42. package/dist/es/component/shiny-text/index.css +107 -0
  43. package/dist/es/component/shiny-text/index.mjs +15 -0
  44. package/dist/es/component/universal-playground/empty-state.mjs +5 -0
  45. package/dist/es/component/universal-playground/index.css +619 -0
  46. package/dist/es/component/universal-playground/index.mjs +558 -0
  47. package/dist/es/component/universal-playground/providers/context-provider.mjs +90 -0
  48. package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +280 -0
  49. package/dist/es/component/universal-playground/providers/storage-provider.mjs +279 -0
  50. package/dist/es/component/universal-playground/universal-playground-electron.mjs +668 -0
  51. package/dist/es/hooks/useMinimalTypeGate.mjs +47 -0
  52. package/dist/es/hooks/usePlaygroundExecution.mjs +435 -0
  53. package/dist/es/hooks/usePlaygroundState.mjs +278 -0
  54. package/dist/es/hooks/useSafeOverrideAIConfig.mjs +20 -0
  55. package/dist/es/hooks/useServerValid.mjs +55 -0
  56. package/dist/es/hooks/useTheme.mjs +25 -0
  57. package/dist/es/icons/action-chevron.mjs +61 -0
  58. package/dist/es/icons/avatar.mjs +70 -0
  59. package/dist/es/icons/close.mjs +61 -0
  60. package/dist/es/icons/global-perspective.mjs +58 -0
  61. package/dist/es/icons/history.mjs +72 -0
  62. package/dist/es/icons/magnifying-glass.mjs +81 -0
  63. package/dist/es/icons/player-setting.mjs +68 -0
  64. package/dist/es/icons/prompt-history.mjs +70 -0
  65. package/dist/es/icons/setting.mjs +62 -0
  66. package/dist/es/icons/show-marker.mjs +58 -0
  67. package/dist/es/index.mjs +26 -0
  68. package/dist/es/static/image/logo.png +0 -0
  69. package/dist/es/store/history.mjs +128 -0
  70. package/dist/es/store/store.mjs +277 -0
  71. package/dist/es/types.mjs +73 -0
  72. package/dist/es/utils/action-label.mjs +15 -0
  73. package/dist/es/utils/color.mjs +35 -0
  74. package/dist/es/utils/constants.mjs +99 -0
  75. package/dist/es/utils/device-capabilities.mjs +13 -0
  76. package/dist/es/utils/empty-state-scroll.mjs +8 -0
  77. package/dist/es/utils/highlight-element.mjs +62 -0
  78. package/dist/es/utils/index.mjs +13 -0
  79. package/dist/es/utils/playground-utils.mjs +43 -0
  80. package/dist/es/utils/progress-action-icon.mjs +30 -0
  81. package/dist/es/utils/prompt-input-utils.mjs +49 -0
  82. package/dist/es/utils/prompt-placeholder.mjs +19 -0
  83. package/dist/es/utils/replay-scripts.mjs +428 -0
  84. package/dist/lib/component/blackboard/highlights.js +84 -0
  85. package/dist/lib/component/blackboard/index.css +118 -0
  86. package/dist/lib/component/blackboard/index.js +169 -0
  87. package/dist/lib/component/config-selector/index.js +295 -0
  88. package/dist/lib/component/context-preview/index.js +82 -0
  89. package/dist/lib/component/env-config/index.js +271 -0
  90. package/dist/lib/component/env-config-reminder/index.css +30 -0
  91. package/dist/lib/component/env-config-reminder/index.js +61 -0
  92. package/dist/lib/component/form-field/index.js +204 -0
  93. package/dist/lib/component/history-selector/index.css +237 -0
  94. package/dist/lib/component/history-selector/index.js +243 -0
  95. package/dist/lib/component/index.js +58 -0
  96. package/dist/lib/component/logo/index.css +19 -0
  97. package/dist/lib/component/logo/index.js +67 -0
  98. package/dist/lib/component/logo/logo.js +24 -0
  99. package/dist/lib/component/misc/index.js +152 -0
  100. package/dist/lib/component/nav-actions/index.js +48 -0
  101. package/dist/lib/component/nav-actions/style.css +35 -0
  102. package/dist/lib/component/player/index.css +296 -0
  103. package/dist/lib/component/player/index.js +747 -0
  104. package/dist/lib/component/player/playback-controls.js +38 -0
  105. package/dist/lib/component/player/report-download.js +98 -0
  106. package/dist/lib/component/player/scenes/StepScene.js +228 -0
  107. package/dist/lib/component/player/scenes/derive-frame-state.js +266 -0
  108. package/dist/lib/component/player/scenes/export-branded-video.js +403 -0
  109. package/dist/lib/component/player/scenes/frame-calculator.js +186 -0
  110. package/dist/lib/component/player/scenes/playback-frame.js +40 -0
  111. package/dist/lib/component/player/scenes/playback-layout.js +46 -0
  112. package/dist/lib/component/player/scenes/pointer-layout.js +88 -0
  113. package/dist/lib/component/player/use-frame-player.js +121 -0
  114. package/dist/lib/component/playground/index.css +930 -0
  115. package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
  116. package/dist/lib/component/playground-result/index.css +92 -0
  117. package/dist/lib/component/playground-result/index.js +276 -0
  118. package/dist/lib/component/prompt-input/index.css +832 -0
  119. package/dist/lib/component/prompt-input/index.js +1005 -0
  120. package/dist/lib/component/screenshot-viewer/index.css +237 -0
  121. package/dist/lib/component/screenshot-viewer/index.js +353 -0
  122. package/dist/lib/component/service-mode-control/index.js +141 -0
  123. package/dist/lib/component/shiny-text/index.css +107 -0
  124. package/dist/lib/component/shiny-text/index.js +49 -0
  125. package/dist/lib/component/universal-playground/empty-state.js +39 -0
  126. package/dist/lib/component/universal-playground/index.css +619 -0
  127. package/dist/lib/component/universal-playground/index.js +607 -0
  128. package/dist/lib/component/universal-playground/providers/context-provider.js +133 -0
  129. package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +320 -0
  130. package/dist/lib/component/universal-playground/providers/storage-provider.js +337 -0
  131. package/dist/lib/component/universal-playground/universal-playground-electron.js +717 -0
  132. package/dist/lib/hooks/useMinimalTypeGate.js +81 -0
  133. package/dist/lib/hooks/usePlaygroundExecution.js +478 -0
  134. package/dist/lib/hooks/usePlaygroundState.js +312 -0
  135. package/dist/lib/hooks/useSafeOverrideAIConfig.js +57 -0
  136. package/dist/lib/hooks/useServerValid.js +89 -0
  137. package/dist/lib/hooks/useTheme.js +59 -0
  138. package/dist/lib/icons/action-chevron.js +95 -0
  139. package/dist/lib/icons/avatar.js +104 -0
  140. package/dist/lib/icons/close.js +95 -0
  141. package/dist/lib/icons/global-perspective.js +92 -0
  142. package/dist/lib/icons/history.js +106 -0
  143. package/dist/lib/icons/magnifying-glass.js +115 -0
  144. package/dist/lib/icons/player-setting.js +102 -0
  145. package/dist/lib/icons/prompt-history.js +104 -0
  146. package/dist/lib/icons/setting.js +96 -0
  147. package/dist/lib/icons/show-marker.js +92 -0
  148. package/dist/lib/index.js +204 -0
  149. package/dist/lib/static/image/logo.png +0 -0
  150. package/dist/lib/store/history.js +135 -0
  151. package/dist/lib/store/store.js +287 -0
  152. package/dist/lib/types.js +119 -0
  153. package/dist/lib/utils/action-label.js +52 -0
  154. package/dist/lib/utils/color.js +75 -0
  155. package/dist/lib/utils/constants.js +172 -0
  156. package/dist/lib/utils/device-capabilities.js +50 -0
  157. package/dist/lib/utils/empty-state-scroll.js +42 -0
  158. package/dist/lib/utils/highlight-element.js +99 -0
  159. package/dist/lib/utils/index.js +69 -0
  160. package/dist/lib/utils/playground-utils.js +86 -0
  161. package/dist/lib/utils/progress-action-icon.js +67 -0
  162. package/dist/lib/utils/prompt-input-utils.js +89 -0
  163. package/dist/lib/utils/prompt-placeholder.js +53 -0
  164. package/dist/lib/utils/replay-scripts.js +474 -0
  165. package/dist/types/component/blackboard/highlights.d.ts +11 -0
  166. package/dist/types/component/blackboard/index.d.ts +10 -0
  167. package/dist/types/component/config-selector/index.d.ts +15 -0
  168. package/dist/types/component/context-preview/index.d.ts +9 -0
  169. package/dist/types/component/env-config/index.d.ts +8 -0
  170. package/dist/types/component/env-config-reminder/index.d.ts +6 -0
  171. package/dist/types/component/form-field/index.d.ts +17 -0
  172. package/dist/types/component/history-selector/index.d.ts +13 -0
  173. package/dist/types/component/index.d.ts +1 -0
  174. package/dist/types/component/logo/index.d.ts +5 -0
  175. package/dist/types/component/misc/index.d.ts +6 -0
  176. package/dist/types/component/nav-actions/index.d.ts +12 -0
  177. package/dist/types/component/player/index.d.ts +15 -0
  178. package/dist/types/component/player/playback-controls.d.ts +1 -0
  179. package/dist/types/component/player/report-download.d.ts +32 -0
  180. package/dist/types/component/player/scenes/StepScene.d.ts +9 -0
  181. package/dist/types/component/player/scenes/derive-frame-state.d.ts +40 -0
  182. package/dist/types/component/player/scenes/export-branded-video.d.ts +33 -0
  183. package/dist/types/component/player/scenes/frame-calculator.d.ts +40 -0
  184. package/dist/types/component/player/scenes/playback-frame.d.ts +3 -0
  185. package/dist/types/component/player/scenes/playback-layout.d.ts +7 -0
  186. package/dist/types/component/player/scenes/pointer-layout.d.ts +20 -0
  187. package/dist/types/component/player/use-frame-player.d.ts +17 -0
  188. package/dist/types/component/playground-result/index.d.ts +22 -0
  189. package/dist/types/component/prompt-input/index.d.ts +23 -0
  190. package/dist/types/component/screenshot-viewer/index.d.ts +23 -0
  191. package/dist/types/component/service-mode-control/index.d.ts +6 -0
  192. package/dist/types/component/shiny-text/index.d.ts +12 -0
  193. package/dist/types/component/universal-playground/empty-state.d.ts +3 -0
  194. package/dist/types/component/universal-playground/index.d.ts +4 -0
  195. package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
  196. package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
  197. package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
  198. package/dist/types/component/universal-playground/universal-playground-electron.d.ts +4 -0
  199. package/dist/types/hooks/useMinimalTypeGate.d.ts +72 -0
  200. package/dist/types/hooks/usePlaygroundExecution.d.ts +40 -0
  201. package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
  202. package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
  203. package/dist/types/hooks/useServerValid.d.ts +1 -0
  204. package/dist/types/hooks/useTheme.d.ts +7 -0
  205. package/dist/types/index.d.ts +29 -0
  206. package/dist/types/store/history.d.ts +16 -0
  207. package/dist/types/store/store.d.ts +57 -0
  208. package/dist/types/types.d.ts +278 -0
  209. package/dist/types/utils/action-label.d.ts +11 -0
  210. package/dist/types/utils/color.d.ts +4 -0
  211. package/dist/types/utils/constants.d.ts +80 -0
  212. package/dist/types/utils/device-capabilities.d.ts +9 -0
  213. package/dist/types/utils/empty-state-scroll.d.ts +11 -0
  214. package/dist/types/utils/highlight-element.d.ts +3 -0
  215. package/dist/types/utils/index.d.ts +5 -0
  216. package/dist/types/utils/playground-utils.d.ts +11 -0
  217. package/dist/types/utils/progress-action-icon.d.ts +12 -0
  218. package/dist/types/utils/prompt-input-utils.d.ts +24 -0
  219. package/dist/types/utils/prompt-placeholder.d.ts +1 -0
  220. package/dist/types/utils/replay-scripts.d.ts +50 -0
  221. package/package.json +82 -0
@@ -0,0 +1,4 @@
1
+ function shouldRestartPlaybackFromBeginning(currentFrame, effectiveEndFrame) {
2
+ return effectiveEndFrame > 0 && currentFrame >= effectiveEndFrame;
3
+ }
4
+ export { shouldRestartPlaybackFromBeginning };
@@ -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 };