@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,403 @@
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 ("u" > 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
+ exportBrandedVideo: ()=>exportBrandedVideo,
28
+ isExportRenderStalled: ()=>isExportRenderStalled,
29
+ projectNativeRectToExportViewport: ()=>projectNativeRectToExportViewport,
30
+ resolveExportCamera: ()=>resolveExportCamera
31
+ });
32
+ const index_js_namespaceObject = require("../../../utils/index.js");
33
+ const highlight_element_js_namespaceObject = require("../../../utils/highlight-element.js");
34
+ const external_derive_frame_state_js_namespaceObject = require("./derive-frame-state.js");
35
+ const external_playback_layout_js_namespaceObject = require("./playback-layout.js");
36
+ const external_pointer_layout_js_namespaceObject = require("./pointer-layout.js");
37
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
38
+ try {
39
+ var info = gen[key](arg);
40
+ var value = info.value;
41
+ } catch (error) {
42
+ reject(error);
43
+ return;
44
+ }
45
+ if (info.done) resolve(value);
46
+ else Promise.resolve(value).then(_next, _throw);
47
+ }
48
+ function _async_to_generator(fn) {
49
+ return function() {
50
+ var self = this, args = arguments;
51
+ return new Promise(function(resolve, reject) {
52
+ var gen = fn.apply(self, args);
53
+ function _next(value) {
54
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
55
+ }
56
+ function _throw(err) {
57
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
58
+ }
59
+ _next(void 0);
60
+ });
61
+ };
62
+ }
63
+ function _define_property(obj, key, value) {
64
+ if (key in obj) Object.defineProperty(obj, key, {
65
+ value: value,
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true
69
+ });
70
+ else obj[key] = value;
71
+ return obj;
72
+ }
73
+ function _object_spread(target) {
74
+ for(var i = 1; i < arguments.length; i++){
75
+ var source = null != arguments[i] ? arguments[i] : {};
76
+ var ownKeys = Object.keys(source);
77
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
78
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
79
+ }));
80
+ ownKeys.forEach(function(key) {
81
+ _define_property(target, key, source[key]);
82
+ });
83
+ }
84
+ return target;
85
+ }
86
+ function export_branded_video_ownKeys(object, enumerableOnly) {
87
+ var keys = Object.keys(object);
88
+ if (Object.getOwnPropertySymbols) {
89
+ var symbols = Object.getOwnPropertySymbols(object);
90
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
91
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
92
+ });
93
+ keys.push.apply(keys, symbols);
94
+ }
95
+ return keys;
96
+ }
97
+ function _object_spread_props(target, source) {
98
+ source = null != source ? source : {};
99
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
100
+ else export_branded_video_ownKeys(Object(source)).forEach(function(key) {
101
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
102
+ });
103
+ return target;
104
+ }
105
+ const W = 960;
106
+ const H = 540;
107
+ const POINTER_PHASE = 0.375;
108
+ const CROSSFADE_FRAMES = 10;
109
+ const EXPORT_STALL_GRACE_MS = 2000;
110
+ const EXPORT_STALL_GRACE_FRAMES = 10;
111
+ let activeExport = false;
112
+ function clamp(v, lo, hi) {
113
+ return Math.min(Math.max(v, lo), hi);
114
+ }
115
+ function lerp(a, b, t) {
116
+ return a + (b - a) * t;
117
+ }
118
+ function isExportRenderStalled(elapsedSinceLastFrameMs, frameDurationMs) {
119
+ return elapsedSinceLastFrameMs > Math.max(EXPORT_STALL_GRACE_MS, frameDurationMs * EXPORT_STALL_GRACE_FRAMES);
120
+ }
121
+ function resolveExportCamera(prevCamera, camera, imageWidth, progress, autoZoom) {
122
+ if (!autoZoom) return {
123
+ camLeft: 0,
124
+ camTop: 0,
125
+ camWidth: imageWidth
126
+ };
127
+ return {
128
+ camLeft: lerp(prevCamera.left, camera.left, progress),
129
+ camTop: lerp(prevCamera.top, camera.top, progress),
130
+ camWidth: lerp(prevCamera.width, camera.width, progress)
131
+ };
132
+ }
133
+ function loadImage(src) {
134
+ return new Promise((resolve, reject)=>{
135
+ const img = new Image();
136
+ img.crossOrigin = 'anonymous';
137
+ img.onload = ()=>resolve(img);
138
+ img.onerror = reject;
139
+ img.src = src;
140
+ });
141
+ }
142
+ function projectNativeRectToExportViewport(rect, cameraTransform, viewport) {
143
+ const scaleX = viewport.contentWidth / viewport.imageWidth;
144
+ const scaleY = viewport.contentHeight / viewport.imageHeight;
145
+ return {
146
+ left: viewport.offsetX + (rect.left * scaleX + cameraTransform.tx) * cameraTransform.zoom,
147
+ top: viewport.offsetY + (rect.top * scaleY + cameraTransform.ty) * cameraTransform.zoom,
148
+ width: rect.width * scaleX * cameraTransform.zoom,
149
+ height: rect.height * scaleY * cameraTransform.zoom
150
+ };
151
+ }
152
+ function drawInsightOverlays(ctx, insights, cameraTransform, viewport) {
153
+ ctx.save();
154
+ ctx.beginPath();
155
+ ctx.rect(viewport.offsetX, viewport.offsetY, viewport.contentWidth, viewport.contentHeight);
156
+ ctx.clip();
157
+ for (const insight of insights)if (!(insight.alpha <= 0)) {
158
+ ctx.save();
159
+ ctx.globalAlpha *= insight.alpha;
160
+ if (insight.highlightElement) {
161
+ const highlightBox = (0, highlight_element_js_namespaceObject.getCenterHighlightBox)(insight.highlightElement);
162
+ const projected = projectNativeRectToExportViewport(highlightBox, cameraTransform, viewport);
163
+ ctx.fillStyle = 'rgba(253, 89, 7, 0.4)';
164
+ ctx.fillRect(projected.left, projected.top, projected.width, projected.height);
165
+ ctx.strokeStyle = '#fd5907';
166
+ ctx.lineWidth = 1;
167
+ ctx.strokeRect(projected.left, projected.top, projected.width, projected.height);
168
+ ctx.shadowColor = 'rgba(51, 51, 51, 0.4)';
169
+ ctx.shadowBlur = 2;
170
+ ctx.shadowOffsetX = 4;
171
+ ctx.shadowOffsetY = 4;
172
+ ctx.strokeRect(projected.left, projected.top, projected.width, projected.height);
173
+ ctx.shadowBlur = 0;
174
+ ctx.shadowOffsetX = 0;
175
+ ctx.shadowOffsetY = 0;
176
+ }
177
+ if (insight.searchArea) {
178
+ const projected = projectNativeRectToExportViewport(insight.searchArea, cameraTransform, viewport);
179
+ ctx.fillStyle = 'rgba(2, 131, 145, 0.4)';
180
+ ctx.fillRect(projected.left, projected.top, projected.width, projected.height);
181
+ ctx.strokeStyle = '#028391';
182
+ ctx.lineWidth = 1;
183
+ ctx.strokeRect(projected.left, projected.top, projected.width, projected.height);
184
+ }
185
+ ctx.restore();
186
+ }
187
+ ctx.restore();
188
+ }
189
+ function drawSpinningPointer(ctx, img, x, y, layout, elapsedMs) {
190
+ const progress = (Math.sin(elapsedMs / 500 - Math.PI / 2) + 1) / 2;
191
+ const rotation = progress * Math.PI * 2;
192
+ ctx.save();
193
+ ctx.translate(x, y);
194
+ ctx.rotate(rotation);
195
+ ctx.drawImage(img, -layout.centerOffsetX, -layout.centerOffsetY, layout.width, layout.height);
196
+ ctx.restore();
197
+ }
198
+ function drawSteps(ctx, stepsFrame, frameMap, imgCache, pointerCache, spinnerImg, autoZoom) {
199
+ var _pointerCache_get;
200
+ const { scriptFrames, imageWidth: baseW, imageHeight: baseH, fps } = frameMap;
201
+ const st = (0, external_derive_frame_state_js_namespaceObject.deriveFrameState)(scriptFrames, stepsFrame, baseW, baseH, fps);
202
+ if (!st.img) return;
203
+ const { img, prevImg, imageWidth: imgW, imageHeight: imgH, camera, prevCamera, pointerMoved, imageChanged, rawProgress, frameInScript: fInScript, spinning, spinningElapsedMs, currentPointerImg, pointerVisible, insights } = st;
204
+ const pT = autoZoom ? pointerMoved ? Math.min(rawProgress / POINTER_PHASE, 1) : rawProgress : 1;
205
+ const cT = pointerMoved ? rawProgress <= POINTER_PHASE ? 0 : Math.min((rawProgress - POINTER_PHASE) / (1 - POINTER_PHASE), 1) : rawProgress;
206
+ const { camLeft: camL, camTop: camT2, camWidth: camW } = resolveExportCamera(prevCamera, camera, imgW, cT, autoZoom);
207
+ const ptrX = lerp(prevCamera.pointerLeft, camera.pointerLeft, pT);
208
+ const ptrY = lerp(prevCamera.pointerTop, camera.pointerTop, pT);
209
+ const zoom = imgW / camW;
210
+ const { offsetX, offsetY, contentWidth, contentHeight } = (0, external_playback_layout_js_namespaceObject.getPlaybackViewport)(W, H, imgW, imgH);
211
+ const tx = contentWidth / imgW * -camL;
212
+ const ty = contentHeight / imgH * -camT2;
213
+ const crossAlpha = imageChanged ? clamp(fInScript / CROSSFADE_FRAMES, 0, 1) : 1;
214
+ ctx.fillStyle = '#000';
215
+ ctx.fillRect(0, 0, W, H);
216
+ const drawImg = (src, alpha)=>{
217
+ const imgEl = imgCache.get(src);
218
+ if (!imgEl || alpha <= 0) return;
219
+ ctx.save();
220
+ ctx.globalAlpha = alpha;
221
+ ctx.beginPath();
222
+ ctx.rect(0, 0, W, H);
223
+ ctx.clip();
224
+ ctx.translate(offsetX + tx * zoom, offsetY + ty * zoom);
225
+ ctx.scale(zoom, zoom);
226
+ ctx.drawImage(imgEl, 0, 0, contentWidth, contentHeight);
227
+ ctx.restore();
228
+ };
229
+ if (imageChanged && prevImg && crossAlpha < 1) drawImg(prevImg, 1 - crossAlpha);
230
+ drawImg(img, imageChanged ? crossAlpha : 1);
231
+ if (insights.length > 0) drawInsightOverlays(ctx, insights, {
232
+ zoom,
233
+ tx,
234
+ ty
235
+ }, {
236
+ offsetX,
237
+ offsetY,
238
+ contentWidth,
239
+ contentHeight,
240
+ imageWidth: imgW,
241
+ imageHeight: imgH
242
+ });
243
+ const camH = imgH / imgW * camW;
244
+ const sX = offsetX + (ptrX - camL) / camW * contentWidth;
245
+ const sY = offsetY + (ptrY - camT2) / camH * contentHeight;
246
+ const pointerLayout = (0, external_pointer_layout_js_namespaceObject.resolveExportPointerLayout)(imgW, contentWidth);
247
+ const spinnerLayout = (0, external_pointer_layout_js_namespaceObject.resolveSpinnerLayout)(pointerLayout);
248
+ const cursorImg = null != (_pointerCache_get = pointerCache.get(currentPointerImg)) ? _pointerCache_get : pointerCache.get(index_js_namespaceObject.mousePointer);
249
+ const showCursor = (0, external_derive_frame_state_js_namespaceObject.shouldRenderCursor)(pointerVisible, camera, prevCamera, imgW, imgH);
250
+ if (spinning && spinnerImg) drawSpinningPointer(ctx, spinnerImg, sX, sY, _object_spread_props(_object_spread({}, pointerLayout), {
251
+ width: spinnerLayout.size,
252
+ height: spinnerLayout.size,
253
+ centerOffsetX: spinnerLayout.centerOffset,
254
+ centerOffsetY: spinnerLayout.centerOffset
255
+ }), spinningElapsedMs);
256
+ if (!spinning && showCursor && cursorImg) ctx.drawImage(cursorImg, sX - pointerLayout.hotspotX, sY - pointerLayout.hotspotY, pointerLayout.width, pointerLayout.height);
257
+ }
258
+ function exportBrandedVideo(frameMap, options, onProgress) {
259
+ return _async_to_generator(function*() {
260
+ if (activeExport) throw new Error('Video export is already in progress');
261
+ activeExport = true;
262
+ try {
263
+ yield runExportBrandedVideo(frameMap, options, onProgress);
264
+ } finally{
265
+ activeExport = false;
266
+ }
267
+ })();
268
+ }
269
+ function runExportBrandedVideo(frameMap, options, onProgress) {
270
+ return _async_to_generator(function*() {
271
+ var _ref;
272
+ const { totalDurationInFrames: total, fps } = frameMap;
273
+ const autoZoom = null != (_ref = null == options ? void 0 : options.autoZoom) ? _ref : true;
274
+ const imgSrcs = new Set();
275
+ for (const sf of frameMap.scriptFrames)if (sf.img) imgSrcs.add(sf.img);
276
+ const imgCache = new Map();
277
+ yield Promise.all([
278
+ ...imgSrcs
279
+ ].map((src)=>_async_to_generator(function*() {
280
+ try {
281
+ imgCache.set(src, (yield loadImage(src)));
282
+ } catch (unused) {}
283
+ })()));
284
+ const pointerSrcs = new Set([
285
+ index_js_namespaceObject.mousePointer
286
+ ]);
287
+ for (const sf of frameMap.scriptFrames)if (sf.pointerImg) pointerSrcs.add(sf.pointerImg);
288
+ const pointerCache = new Map();
289
+ yield Promise.all([
290
+ ...pointerSrcs
291
+ ].map((src)=>_async_to_generator(function*() {
292
+ try {
293
+ pointerCache.set(src, (yield loadImage(src)));
294
+ } catch (unused) {}
295
+ })()));
296
+ let spinnerImg = null;
297
+ try {
298
+ spinnerImg = yield loadImage(index_js_namespaceObject.mouseLoading);
299
+ } catch (unused) {}
300
+ const canvas = document.createElement('canvas');
301
+ canvas.width = W;
302
+ canvas.height = H;
303
+ const ctx = canvas.getContext('2d');
304
+ const stream = canvas.captureStream(fps);
305
+ const recorder = new MediaRecorder(stream, {
306
+ mimeType: 'video/webm'
307
+ });
308
+ const chunks = [];
309
+ recorder.ondataavailable = (e)=>{
310
+ if (e.data.size > 0) chunks.push(e.data);
311
+ };
312
+ return new Promise((resolve, reject)=>{
313
+ let stoppedByError = null;
314
+ let settled = false;
315
+ let nextFrame = 0;
316
+ let nextFrameDueAt = performance.now();
317
+ let lastFrameAt = nextFrameDueAt;
318
+ let stopTimer = null;
319
+ let renderTimer = null;
320
+ const frameDuration = 1000 / fps;
321
+ const cleanup = ()=>{
322
+ if (stopTimer) clearTimeout(stopTimer);
323
+ if (renderTimer) clearTimeout(renderTimer);
324
+ document.removeEventListener('visibilitychange', handleVisibilityChange);
325
+ stream.getTracks().forEach((track)=>track.stop());
326
+ };
327
+ const finishWithError = (error)=>{
328
+ if (settled || stoppedByError) return;
329
+ stoppedByError = error;
330
+ if ('inactive' !== recorder.state) recorder.stop();
331
+ else {
332
+ cleanup();
333
+ settled = true;
334
+ reject(error);
335
+ }
336
+ };
337
+ const handleVisibilityChange = ()=>{
338
+ if (document.hidden) finishWithError(new Error('Video export was interrupted because the report tab was hidden'));
339
+ };
340
+ recorder.onerror = ()=>{
341
+ finishWithError(new Error('MediaRecorder error'));
342
+ };
343
+ recorder.onstop = ()=>{
344
+ cleanup();
345
+ if (settled) return;
346
+ settled = true;
347
+ if (stoppedByError) return void reject(stoppedByError);
348
+ if (0 === chunks.length) return void reject(new Error('No video data'));
349
+ const blob = new Blob(chunks, {
350
+ type: 'video/webm'
351
+ });
352
+ const url = URL.createObjectURL(blob);
353
+ const a = document.createElement('a');
354
+ a.href = url;
355
+ a.download = 'midscene_replay.webm';
356
+ a.click();
357
+ setTimeout(()=>URL.revokeObjectURL(url), 1000);
358
+ resolve();
359
+ };
360
+ document.addEventListener('visibilitychange', handleVisibilityChange);
361
+ recorder.start();
362
+ const scheduleNextFrame = ()=>{
363
+ const delay = Math.max(0, nextFrameDueAt - performance.now());
364
+ renderTimer = setTimeout(()=>{
365
+ requestAnimationFrame(renderFrame);
366
+ }, delay);
367
+ };
368
+ const renderFrame = (timestamp)=>{
369
+ if (settled || 'inactive' === recorder.state) return;
370
+ if (nextFrame > 0 && isExportRenderStalled(timestamp - lastFrameAt, frameDuration)) return void finishWithError(new Error('Video export was interrupted because rendering stalled'));
371
+ lastFrameAt = timestamp;
372
+ ctx.clearRect(0, 0, W, H);
373
+ drawSteps(ctx, nextFrame, frameMap, imgCache, pointerCache, spinnerImg, autoZoom);
374
+ null == onProgress || onProgress((nextFrame + 1) / total);
375
+ nextFrame += 1;
376
+ if (nextFrame < total) {
377
+ nextFrameDueAt += frameDuration;
378
+ scheduleNextFrame();
379
+ } else stopTimer = setTimeout(()=>{
380
+ if ('inactive' !== recorder.state) recorder.stop();
381
+ }, 2 * frameDuration);
382
+ };
383
+ requestAnimationFrame((timestamp)=>{
384
+ lastFrameAt = timestamp;
385
+ nextFrameDueAt = timestamp;
386
+ renderFrame(timestamp);
387
+ });
388
+ });
389
+ })();
390
+ }
391
+ exports.exportBrandedVideo = __webpack_exports__.exportBrandedVideo;
392
+ exports.isExportRenderStalled = __webpack_exports__.isExportRenderStalled;
393
+ exports.projectNativeRectToExportViewport = __webpack_exports__.projectNativeRectToExportViewport;
394
+ exports.resolveExportCamera = __webpack_exports__.resolveExportCamera;
395
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
396
+ "exportBrandedVideo",
397
+ "isExportRenderStalled",
398
+ "projectNativeRectToExportViewport",
399
+ "resolveExportCamera"
400
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
401
+ Object.defineProperty(exports, '__esModule', {
402
+ value: true
403
+ });
@@ -0,0 +1,186 @@
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 ("u" > 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
+ FPS: ()=>FPS,
28
+ calculateFrameMap: ()=>calculateFrameMap
29
+ });
30
+ const FPS = 30;
31
+ function calculateFrameMap(scripts, options) {
32
+ let baseImageWidth = (null == options ? void 0 : options.imageWidth) || 1920;
33
+ let baseImageHeight = (null == options ? void 0 : options.imageHeight) || 1080;
34
+ for (const s of scripts)if (('img' === s.type || 'insight' === s.type) && s.img) {
35
+ baseImageWidth = s.imageWidth || baseImageWidth;
36
+ baseImageHeight = s.imageHeight || baseImageHeight;
37
+ break;
38
+ }
39
+ const scriptFrames = [];
40
+ let currentFrame = 0;
41
+ for (const script of scripts){
42
+ const durationMs = script.duration;
43
+ switch(script.type){
44
+ case 'sleep':
45
+ {
46
+ const frames = Math.ceil(durationMs / 1000 * FPS);
47
+ scriptFrames.push({
48
+ type: 'sleep',
49
+ startFrame: currentFrame,
50
+ durationInFrames: frames,
51
+ title: script.title,
52
+ subTitle: script.subTitle,
53
+ taskId: script.taskId
54
+ });
55
+ currentFrame += frames;
56
+ break;
57
+ }
58
+ case 'img':
59
+ {
60
+ const frames = Math.max(Math.ceil(durationMs / 1000 * FPS), 1);
61
+ const camera = script.camera;
62
+ const iw = script.imageWidth || baseImageWidth;
63
+ const ih = script.imageHeight || baseImageHeight;
64
+ const sf = {
65
+ type: 'img',
66
+ startFrame: currentFrame,
67
+ durationInFrames: frames,
68
+ img: script.img,
69
+ imageWidth: iw,
70
+ imageHeight: ih,
71
+ title: script.title,
72
+ subTitle: script.subTitle,
73
+ taskId: script.taskId
74
+ };
75
+ if (camera) {
76
+ var _camera_pointerLeft, _camera_pointerTop;
77
+ sf.cameraTarget = {
78
+ left: camera.left,
79
+ top: camera.top,
80
+ width: camera.width,
81
+ pointerLeft: null != (_camera_pointerLeft = camera.pointerLeft) ? _camera_pointerLeft : Math.round(iw / 2),
82
+ pointerTop: null != (_camera_pointerTop = camera.pointerTop) ? _camera_pointerTop : Math.round(ih / 2)
83
+ };
84
+ }
85
+ scriptFrames.push(sf);
86
+ currentFrame += frames;
87
+ break;
88
+ }
89
+ case 'insight':
90
+ {
91
+ const insightPhaseFrames = Math.max(Math.ceil(durationMs / 1000 * FPS), 1);
92
+ const cameraDurationMs = script.insightCameraDuration || 0;
93
+ const cameraPhaseFrames = Math.ceil(cameraDurationMs / 1000 * FPS);
94
+ const totalFrames = insightPhaseFrames + cameraPhaseFrames;
95
+ const iw = script.imageWidth || baseImageWidth;
96
+ const ih = script.imageHeight || baseImageHeight;
97
+ const camera = script.camera;
98
+ const sf = {
99
+ type: 'insight',
100
+ startFrame: currentFrame,
101
+ durationInFrames: totalFrames,
102
+ img: script.img,
103
+ imageWidth: iw,
104
+ imageHeight: ih,
105
+ insightPhaseFrames,
106
+ cameraPhaseFrames,
107
+ highlightElement: script.highlightElement,
108
+ searchArea: script.searchArea,
109
+ title: script.title,
110
+ subTitle: script.subTitle,
111
+ taskId: script.taskId
112
+ };
113
+ if (camera) {
114
+ var _camera_pointerLeft1, _camera_pointerTop1;
115
+ sf.cameraTarget = {
116
+ left: camera.left,
117
+ top: camera.top,
118
+ width: camera.width,
119
+ pointerLeft: null != (_camera_pointerLeft1 = camera.pointerLeft) ? _camera_pointerLeft1 : Math.round(iw / 2),
120
+ pointerTop: null != (_camera_pointerTop1 = camera.pointerTop) ? _camera_pointerTop1 : Math.round(ih / 2)
121
+ };
122
+ }
123
+ scriptFrames.push(sf);
124
+ currentFrame += totalFrames;
125
+ break;
126
+ }
127
+ case 'clear-insight':
128
+ {
129
+ const frames = Math.max(Math.ceil(durationMs / 1000 * FPS), 1);
130
+ scriptFrames.push({
131
+ type: 'clear-insight',
132
+ startFrame: currentFrame,
133
+ durationInFrames: frames,
134
+ title: script.title,
135
+ subTitle: script.subTitle,
136
+ taskId: script.taskId
137
+ });
138
+ currentFrame += frames;
139
+ break;
140
+ }
141
+ case 'spinning-pointer':
142
+ {
143
+ const frames = Math.max(Math.ceil(durationMs / 1000 * FPS), 1);
144
+ scriptFrames.push({
145
+ type: 'spinning-pointer',
146
+ startFrame: currentFrame,
147
+ durationInFrames: frames,
148
+ title: script.title,
149
+ subTitle: script.subTitle,
150
+ taskId: script.taskId
151
+ });
152
+ currentFrame += frames;
153
+ break;
154
+ }
155
+ case 'pointer':
156
+ scriptFrames.push({
157
+ type: 'pointer',
158
+ startFrame: currentFrame,
159
+ durationInFrames: 0,
160
+ pointerImg: script.img,
161
+ title: script.title,
162
+ subTitle: script.subTitle,
163
+ taskId: script.taskId
164
+ });
165
+ break;
166
+ }
167
+ }
168
+ const stepsDurationInFrames = Math.max(currentFrame, 1);
169
+ return {
170
+ scriptFrames,
171
+ totalDurationInFrames: stepsDurationInFrames,
172
+ fps: FPS,
173
+ stepsDurationInFrames,
174
+ imageWidth: baseImageWidth,
175
+ imageHeight: baseImageHeight
176
+ };
177
+ }
178
+ exports.FPS = __webpack_exports__.FPS;
179
+ exports.calculateFrameMap = __webpack_exports__.calculateFrameMap;
180
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
181
+ "FPS",
182
+ "calculateFrameMap"
183
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
184
+ Object.defineProperty(exports, '__esModule', {
185
+ value: true
186
+ });
@@ -0,0 +1,40 @@
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 ("u" > 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
+ getPlaybackFrameState: ()=>getPlaybackFrameState
28
+ });
29
+ const external_derive_frame_state_js_namespaceObject = require("./derive-frame-state.js");
30
+ function getPlaybackFrameState(frameMap, frame) {
31
+ const state = (0, external_derive_frame_state_js_namespaceObject.deriveFrameState)(frameMap.scriptFrames, frame, frameMap.imageWidth, frameMap.imageHeight, frameMap.fps);
32
+ return state.img ? state : null;
33
+ }
34
+ exports.getPlaybackFrameState = __webpack_exports__.getPlaybackFrameState;
35
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
36
+ "getPlaybackFrameState"
37
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
38
+ Object.defineProperty(exports, '__esModule', {
39
+ value: true
40
+ });
@@ -0,0 +1,46 @@
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 ("u" > 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
+ getPlaybackViewport: ()=>getPlaybackViewport
28
+ });
29
+ function getPlaybackViewport(containerWidth, containerHeight, imageWidth, imageHeight) {
30
+ const scale = Math.min(containerWidth / imageWidth, containerHeight / imageHeight);
31
+ const contentWidth = imageWidth * scale;
32
+ const contentHeight = imageHeight * scale;
33
+ return {
34
+ offsetX: (containerWidth - contentWidth) / 2,
35
+ offsetY: (containerHeight - contentHeight) / 2,
36
+ contentWidth,
37
+ contentHeight
38
+ };
39
+ }
40
+ exports.getPlaybackViewport = __webpack_exports__.getPlaybackViewport;
41
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
42
+ "getPlaybackViewport"
43
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
44
+ Object.defineProperty(exports, '__esModule', {
45
+ value: true
46
+ });