@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,43 @@
1
+ import { StaticPage, StaticPageAgent } from "@godscene/web/static";
2
+ import { isZodObjectSchema, unwrapZodType } from "../types.mjs";
3
+ import { actionNameForType } from "./action-label.mjs";
4
+ import { getPlaceholderForType } from "./prompt-placeholder.mjs";
5
+ const staticAgentFromContext = (context)=>{
6
+ const page = new StaticPage(context);
7
+ return new StaticPageAgent(page);
8
+ };
9
+ const isRunButtonEnabled = (runButtonEnabled, needsStructuredParams, params, actionSpace, selectedType, promptValue)=>{
10
+ if (!runButtonEnabled) return false;
11
+ const needsAnyInput = (()=>{
12
+ if (actionSpace) {
13
+ const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
14
+ if (action) {
15
+ if (!action.paramSchema) return false;
16
+ if ('object' == typeof action.paramSchema && 'shape' in action.paramSchema) {
17
+ const shape = action.paramSchema.shape || {};
18
+ const shapeKeys = Object.keys(shape);
19
+ return shapeKeys.length > 0;
20
+ }
21
+ }
22
+ }
23
+ return true;
24
+ })();
25
+ if (!needsAnyInput) return true;
26
+ if (needsStructuredParams) {
27
+ const currentParams = params || {};
28
+ const action = null == actionSpace ? void 0 : actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
29
+ if ((null == action ? void 0 : action.paramSchema) && isZodObjectSchema(action.paramSchema)) {
30
+ const schema = action.paramSchema;
31
+ const shape = schema.shape || {};
32
+ return Object.keys(shape).every((key)=>{
33
+ const field = shape[key];
34
+ const { isOptional } = unwrapZodType(field);
35
+ const value = currentParams[key];
36
+ return isOptional || void 0 !== value && '' !== value && null !== value;
37
+ });
38
+ }
39
+ return true;
40
+ }
41
+ return promptValue.trim().length > 0;
42
+ };
43
+ export { actionNameForType, getPlaceholderForType, isRunButtonEnabled, staticAgentFromContext };
@@ -0,0 +1,30 @@
1
+ import { createElement } from "react";
2
+ function CompletedActionIcon() {
3
+ return /*#__PURE__*/ createElement('svg', {
4
+ width: 16,
5
+ height: 16,
6
+ viewBox: '0 0 24 24',
7
+ fill: 'none',
8
+ xmlns: 'http://www.w3.org/2000/svg',
9
+ 'aria-hidden': true,
10
+ focusable: false
11
+ }, /*#__PURE__*/ createElement('path', {
12
+ d: 'M7.3335 12L10.6668 15.3334L17.3335 8.66669',
13
+ stroke: '#188F4D',
14
+ strokeWidth: '1.33333',
15
+ strokeLinecap: 'round',
16
+ strokeLinejoin: 'round'
17
+ }));
18
+ }
19
+ function defaultProgressActionIcon(_kind) {
20
+ return /*#__PURE__*/ createElement(CompletedActionIcon);
21
+ }
22
+ function resolveProgressActionIcon(kind, override) {
23
+ if (!kind) return null;
24
+ if (override) {
25
+ const custom = override(kind);
26
+ if (void 0 !== custom) return custom;
27
+ }
28
+ return defaultProgressActionIcon(kind);
29
+ }
30
+ export { defaultProgressActionIcon, resolveProgressActionIcon };
@@ -0,0 +1,49 @@
1
+ import { isLocateField, isZodObjectSchema, unwrapZodType } from "../types.mjs";
2
+ import { apiMetadata } from "./constants.mjs";
3
+ const getAvailablePromptActionTypes = (actionSpace)=>{
4
+ const metadataMethods = Object.keys(apiMetadata);
5
+ if (!(null == actionSpace ? void 0 : actionSpace.length)) return metadataMethods;
6
+ const availableMethods = actionSpace.map((action)=>action.interfaceAlias || action.name);
7
+ const finalMethods = new Set();
8
+ metadataMethods.forEach((method)=>{
9
+ const methodInfo = apiMetadata[method];
10
+ if ('aiAct' === method) return void finalMethods.add(method);
11
+ if ((null == methodInfo ? void 0 : methodInfo.group) === 'extraction' || (null == methodInfo ? void 0 : methodInfo.group) === 'validation') return void finalMethods.add(method);
12
+ if (availableMethods.includes(method)) finalMethods.add(method);
13
+ });
14
+ availableMethods.forEach((method)=>{
15
+ finalMethods.add(method);
16
+ });
17
+ return Array.from(finalMethods);
18
+ };
19
+ const getInlineStructuredFieldConfig = (actionSpace, selectedType)=>{
20
+ var _actualField__def, _actualField__def1;
21
+ if (!(null == actionSpace ? void 0 : actionSpace.length) || !selectedType) return null;
22
+ const action = actionSpace.find((item)=>item.interfaceAlias === selectedType || item.name === selectedType);
23
+ if (!(null == action ? void 0 : action.paramSchema) || !isZodObjectSchema(action.paramSchema)) return null;
24
+ const schema = action.paramSchema;
25
+ const shape = schema.shape || {};
26
+ const keys = Object.keys(shape);
27
+ if (1 !== keys.length) return null;
28
+ const [name] = keys;
29
+ const field = shape[name];
30
+ const { actualField } = unwrapZodType(field);
31
+ const isLocate = isLocateField(actualField);
32
+ const fieldType = null == (_actualField__def = actualField._def) ? void 0 : _actualField__def.typeName;
33
+ const isInlineField = 'ZodString' === fieldType || isLocate;
34
+ if (!isInlineField) return null;
35
+ const placeholder = (null == (_actualField__def1 = actualField._def) ? void 0 : _actualField__def1.description) || actualField.description || (isLocate ? 'Describe the element you want to interact with' : `Enter ${name}`);
36
+ return {
37
+ name,
38
+ placeholder
39
+ };
40
+ };
41
+ const shouldOffsetEmptyStateForPromptInput = (actionSpace, selectedType)=>{
42
+ if (!(null == actionSpace ? void 0 : actionSpace.length) || !selectedType) return false;
43
+ if (getInlineStructuredFieldConfig(actionSpace, selectedType)) return false;
44
+ const action = actionSpace.find((item)=>item.interfaceAlias === selectedType || item.name === selectedType);
45
+ if (!(null == action ? void 0 : action.paramSchema) || !isZodObjectSchema(action.paramSchema)) return false;
46
+ const schema = action.paramSchema;
47
+ return Object.keys(schema.shape || {}).length > 1;
48
+ };
49
+ export { getAvailablePromptActionTypes, getInlineStructuredFieldConfig, shouldOffsetEmptyStateForPromptInput };
@@ -0,0 +1,19 @@
1
+ const getPlaceholderForType = (type)=>{
2
+ if ('aiQuery' === type) return 'What do you want to query?';
3
+ if ('aiAssert' === type) return 'What do you want to assert?';
4
+ if ('aiTap' === type) return 'What element do you want to tap?';
5
+ if ('aiDoubleClick' === type) return 'What element do you want to double-click?';
6
+ if ('aiHover' === type) return 'What element do you want to hover over?';
7
+ if ('aiInput' === type) return 'Format: <value> | <element>\nExample: hello world | search box';
8
+ if ('aiRightClick' === type) return 'What element do you want to right-click?';
9
+ if ('aiKeyboardPress' === type) return 'Format: <key> | <element (optional)>\nExample: Enter | text field';
10
+ if ('aiScroll' === type) return 'Format: <direction> <amount> | <element (optional)>\nExample: down 500 | main content';
11
+ if ('aiLocate' === type) return 'What element do you want to locate?';
12
+ if ('aiBoolean' === type) return 'What do you want to check (returns true/false)?';
13
+ if ('aiNumber' === type) return 'What number do you want to extract?';
14
+ if ('aiString' === type) return 'What text do you want to extract?';
15
+ if ('aiAsk' === type) return 'What do you want to ask?';
16
+ if ('aiWaitFor' === type) return 'What condition do you want to wait for?';
17
+ return 'What do you want to do?';
18
+ };
19
+ export { getPlaceholderForType };
@@ -0,0 +1,428 @@
1
+ "use client";
2
+ import { mousePointer } from "./index.mjs";
3
+ import { paramStr, typeStr } from "@godscene/core/agent";
4
+ import { getCenterHighlightBox, normalizeHighlightElementForReport } from "./highlight-element.mjs";
5
+ function _define_property(obj, key, value) {
6
+ if (key in obj) Object.defineProperty(obj, key, {
7
+ value: value,
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true
11
+ });
12
+ else obj[key] = value;
13
+ return obj;
14
+ }
15
+ function _object_spread(target) {
16
+ for(var i = 1; i < arguments.length; i++){
17
+ var source = null != arguments[i] ? arguments[i] : {};
18
+ var ownKeys = Object.keys(source);
19
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ ownKeys.forEach(function(key) {
23
+ _define_property(target, key, source[key]);
24
+ });
25
+ }
26
+ return target;
27
+ }
28
+ function replay_scripts_ownKeys(object, enumerableOnly) {
29
+ var keys = Object.keys(object);
30
+ if (Object.getOwnPropertySymbols) {
31
+ var symbols = Object.getOwnPropertySymbols(object);
32
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
33
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
34
+ });
35
+ keys.push.apply(keys, symbols);
36
+ }
37
+ return keys;
38
+ }
39
+ function _object_spread_props(target, source) {
40
+ source = null != source ? source : {};
41
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
42
+ else replay_scripts_ownKeys(Object(source)).forEach(function(key) {
43
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
44
+ });
45
+ return target;
46
+ }
47
+ const stillDuration = 900;
48
+ const actionSpinningPointerDuration = 300;
49
+ const stillAfterInsightDuration = 300;
50
+ const locateDuration = 800;
51
+ const actionDuration = 500;
52
+ const clearInsightDuration = 200;
53
+ const lastFrameDuration = 200;
54
+ const cameraStateForRect = (rect, imageWidth, imageHeight)=>{
55
+ const canvasRatio = imageWidth / imageHeight;
56
+ const rectRatio = rect.width / rect.height;
57
+ let rectWidthOnPage;
58
+ rectWidthOnPage = rectRatio >= canvasRatio ? rect.width : rect.height / imageHeight * imageWidth;
59
+ const cameraPaddingRatio = rectWidthOnPage > 400 ? 0.1 : rectWidthOnPage > 50 ? 0.2 : 0.3;
60
+ const cameraWidth = Math.min(imageWidth, rectWidthOnPage + imageWidth * cameraPaddingRatio * 2);
61
+ const cameraHeight = imageHeight / imageWidth * cameraWidth;
62
+ let left = Math.min(rect.left - imageWidth * cameraPaddingRatio, imageWidth - cameraWidth);
63
+ left = Math.max(left, 0);
64
+ let top = Math.min(rect.top - imageHeight * cameraPaddingRatio, imageHeight - cameraHeight);
65
+ top = Math.max(top, 0);
66
+ return {
67
+ left: Math.round(left),
68
+ top: Math.round(top),
69
+ width: Math.round(cameraWidth)
70
+ };
71
+ };
72
+ const createFullPageCameraState = (imageWidth, imageHeight)=>cameraStateForRect({
73
+ left: 0,
74
+ top: 0,
75
+ width: imageWidth,
76
+ height: imageHeight
77
+ }, imageWidth, imageHeight);
78
+ const resolveTaskShotSize = (task, fallbackWidth, fallbackHeight)=>{
79
+ var _task_uiContext_shotSize, _task_uiContext, _task_uiContext_shotSize1, _task_uiContext1;
80
+ return {
81
+ width: (null == task ? void 0 : null == (_task_uiContext = task.uiContext) ? void 0 : null == (_task_uiContext_shotSize = _task_uiContext.shotSize) ? void 0 : _task_uiContext_shotSize.width) || fallbackWidth,
82
+ height: (null == task ? void 0 : null == (_task_uiContext1 = task.uiContext) ? void 0 : null == (_task_uiContext_shotSize1 = _task_uiContext1.shotSize) ? void 0 : _task_uiContext_shotSize1.height) || fallbackHeight
83
+ };
84
+ };
85
+ const mergeTwoCameraState = (cameraState1, cameraState2)=>{
86
+ const newLeft = Math.min(cameraState1.left, cameraState2.left);
87
+ const newTop = Math.min(cameraState1.top, cameraState2.top);
88
+ const newRight = Math.max(cameraState1.left + cameraState1.width, cameraState2.left + cameraState2.width);
89
+ const newWidth = newRight - newLeft;
90
+ return {
91
+ left: newLeft,
92
+ top: newTop,
93
+ width: newWidth
94
+ };
95
+ };
96
+ const isSameModelBrief = (a, b)=>a.intent === b.intent && a.name === b.name && a.modelDescription === b.modelDescription;
97
+ const pushModelBriefIfNotExists = (list, candidate)=>{
98
+ if (!list.some((brief)=>isSameModelBrief(brief, candidate))) list.push(candidate);
99
+ };
100
+ const normalizeDump = (dump)=>{
101
+ if (!dump) return null;
102
+ return Array.isArray(dump.executions) ? dump : {
103
+ sdkVersion: '',
104
+ groupName: 'Execution',
105
+ modelBriefs: [],
106
+ executions: [
107
+ dump
108
+ ]
109
+ };
110
+ };
111
+ const extractMetaFromNormalized = (normalizedDump)=>{
112
+ var _normalizedDump_executions;
113
+ let firstWidth;
114
+ let firstHeight;
115
+ const sdkVersion = normalizedDump.sdkVersion;
116
+ const modelBriefs = [];
117
+ null == (_normalizedDump_executions = normalizedDump.executions) || _normalizedDump_executions.filter(Boolean).forEach((execution)=>{
118
+ execution.tasks.forEach((task)=>{
119
+ var _task_uiContext_shotSize, _task_uiContext;
120
+ if (null == (_task_uiContext = task.uiContext) ? void 0 : null == (_task_uiContext_shotSize = _task_uiContext.shotSize) ? void 0 : _task_uiContext_shotSize.width) {
121
+ const w = task.uiContext.shotSize.width;
122
+ const h = task.uiContext.shotSize.height;
123
+ if (!firstWidth) {
124
+ firstWidth = w;
125
+ firstHeight = h;
126
+ }
127
+ }
128
+ if (task.usage) {
129
+ const { model_name, model_description, intent } = task.usage;
130
+ const brief = {
131
+ intent,
132
+ name: model_name,
133
+ modelDescription: model_description
134
+ };
135
+ pushModelBriefIfNotExists(modelBriefs, brief);
136
+ }
137
+ });
138
+ });
139
+ if (!firstWidth || !firstHeight) {
140
+ console.warn('width or height is missing in dump file');
141
+ return null;
142
+ }
143
+ return {
144
+ width: firstWidth,
145
+ height: firstHeight,
146
+ sdkVersion,
147
+ modelBriefs,
148
+ deviceType: normalizedDump.deviceType
149
+ };
150
+ };
151
+ const extractDumpMetaInfo = (dump)=>{
152
+ const normalizedDump = normalizeDump(dump);
153
+ if (!normalizedDump) return null;
154
+ return extractMetaFromNormalized(normalizedDump);
155
+ };
156
+ const allScriptsFromDump = (dump)=>{
157
+ var _normalizedDump_executions;
158
+ const normalizedDump = normalizeDump(dump);
159
+ if (!normalizedDump) {
160
+ console.warn('[allScriptsFromDump] dump is empty');
161
+ return {
162
+ scripts: [],
163
+ modelBriefs: []
164
+ };
165
+ }
166
+ const metaInfo = extractMetaFromNormalized(normalizedDump);
167
+ if (!metaInfo) return {
168
+ scripts: [],
169
+ sdkVersion: normalizedDump.sdkVersion,
170
+ modelBriefs: []
171
+ };
172
+ const { width: firstWidth, height: firstHeight } = metaInfo;
173
+ const allScripts = [];
174
+ const executions = (null == (_normalizedDump_executions = normalizedDump.executions) ? void 0 : _normalizedDump_executions.filter(Boolean)) || [];
175
+ for(let execIndex = 0; execIndex < executions.length; execIndex++){
176
+ const execution = executions[execIndex];
177
+ const scripts = generateAnimationScripts(execution, -1, firstWidth, firstHeight, execIndex);
178
+ if (scripts) allScripts.push(...scripts);
179
+ }
180
+ const allScriptsWithoutIntermediateDoneFrame = allScripts.filter((script, index)=>{
181
+ if (index !== allScripts.length - 1 && 'Done' === script.title) return false;
182
+ return true;
183
+ });
184
+ return {
185
+ scripts: allScriptsWithoutIntermediateDoneFrame,
186
+ width: firstWidth,
187
+ height: firstHeight,
188
+ sdkVersion: metaInfo.sdkVersion,
189
+ modelBriefs: metaInfo.modelBriefs,
190
+ deviceType: metaInfo.deviceType
191
+ };
192
+ };
193
+ const generateAnimationScripts = (execution, task, imageWidth, imageHeight, executionIndex = 0)=>{
194
+ if (!execution || !execution.tasks.length) return null;
195
+ if (0 === imageWidth || 0 === imageHeight) return null;
196
+ let tasksIncluded = [];
197
+ if (-1 === task) tasksIncluded = execution.tasks;
198
+ else {
199
+ const startIndex = execution.tasks.findIndex((t)=>t === task);
200
+ if (-1 === startIndex) {
201
+ console.error("task not found, cannot generate animation scripts");
202
+ return null;
203
+ }
204
+ if (startIndex === execution.tasks.length - 1) return null;
205
+ for(let i = startIndex; i < execution.tasks.length; i++){
206
+ if (i > startIndex && 'Planning' === execution.tasks[i].type && 'Plan' === execution.tasks[i].subType) break;
207
+ tasksIncluded.push(execution.tasks[i]);
208
+ }
209
+ }
210
+ if (0 === tasksIncluded.length) return null;
211
+ const getTaskId = (taskIndex)=>{
212
+ var _tasksIncluded_taskIndex;
213
+ return null == (_tasksIncluded_taskIndex = tasksIncluded[taskIndex]) ? void 0 : _tasksIncluded_taskIndex.taskId;
214
+ };
215
+ const setPointerScript = (img, title, subTitle, taskId)=>({
216
+ type: 'pointer',
217
+ img,
218
+ duration: 0,
219
+ title,
220
+ subTitle,
221
+ taskId
222
+ });
223
+ const asScreenshot = (s)=>s;
224
+ const createScript = (base, screenshot)=>{
225
+ if (!screenshot) return base;
226
+ const script = _object_spread({}, base);
227
+ let cachedImg = null;
228
+ Object.defineProperty(script, 'img', {
229
+ get () {
230
+ if (null === cachedImg) cachedImg = screenshot.base64;
231
+ return cachedImg;
232
+ },
233
+ enumerable: true
234
+ });
235
+ return script;
236
+ };
237
+ const scripts = [];
238
+ let insightCameraState;
239
+ let insightOnTop = false;
240
+ let initSubTitle = '';
241
+ let lastTaskId;
242
+ tasksIncluded.forEach((task, index)=>{
243
+ const currentTaskId = getTaskId(index);
244
+ lastTaskId = currentTaskId;
245
+ if (0 === index) initSubTitle = paramStr(task);
246
+ if ('Planning' === task.type) {
247
+ var _task_output;
248
+ let locateElements = [];
249
+ if ('Plan' === task.subType) {
250
+ var _planTask_output;
251
+ const planTask = task;
252
+ const actions = (null == (_planTask_output = planTask.output) ? void 0 : _planTask_output.actions) || [];
253
+ if (actions.length > 0) {
254
+ const action = actions[0];
255
+ const knownFields = [
256
+ 'locate',
257
+ 'start',
258
+ 'end'
259
+ ];
260
+ if (action.param) {
261
+ knownFields.forEach((field)=>{
262
+ if (action.param[field] && 'object' == typeof action.param[field] && 'center' in (action.param[field] || {})) locateElements.push(action.param[field]);
263
+ });
264
+ for(const key in action.param)if (!knownFields.includes(key)) {
265
+ if ('object' == typeof action.param[key] && 'center' in (action.param[key] || {})) locateElements.push(action.param[key]);
266
+ }
267
+ }
268
+ }
269
+ } else if ('Locate' === task.subType && (null == (_task_output = task.output) ? void 0 : _task_output.element)) {
270
+ const locateTask = task;
271
+ locateElements = [
272
+ locateTask.output.element
273
+ ];
274
+ }
275
+ const title = typeStr(task);
276
+ const subTitle = paramStr(task);
277
+ const context = task.uiContext;
278
+ if (null == context ? void 0 : context.screenshot) {
279
+ var _context_shotSize, _context_shotSize1;
280
+ const width = (null == (_context_shotSize = context.shotSize) ? void 0 : _context_shotSize.width) || imageWidth;
281
+ const height = (null == (_context_shotSize1 = context.shotSize) ? void 0 : _context_shotSize1.height) || imageHeight;
282
+ const contextScreenshot = asScreenshot(context.screenshot);
283
+ scripts.push(createScript({
284
+ type: 'img',
285
+ duration: stillAfterInsightDuration,
286
+ title,
287
+ subTitle,
288
+ imageWidth: width,
289
+ imageHeight: height,
290
+ taskId: currentTaskId
291
+ }, contextScreenshot));
292
+ locateElements.forEach((element)=>{
293
+ var _task_log_taskInfo, _task_log, _context_shotSize, _context_shotSize1;
294
+ const highlightElement = normalizeHighlightElementForReport(element);
295
+ const highlightBox = getCenterHighlightBox(highlightElement);
296
+ insightCameraState = _object_spread_props(_object_spread({}, cameraStateForRect(highlightBox, width, height)), {
297
+ pointerLeft: highlightElement.center[0],
298
+ pointerTop: highlightElement.center[1]
299
+ });
300
+ const newCameraState = insightCameraState;
301
+ scripts.push(createScript({
302
+ type: 'insight',
303
+ context: context,
304
+ camera: newCameraState,
305
+ highlightElement,
306
+ searchArea: null == (_task_log = task.log) ? void 0 : null == (_task_log_taskInfo = _task_log.taskInfo) ? void 0 : _task_log_taskInfo.searchArea,
307
+ duration: 0.5 * locateDuration,
308
+ insightCameraDuration: locateDuration,
309
+ title,
310
+ subTitle: highlightElement.description || subTitle,
311
+ imageWidth: (null == (_context_shotSize = context.shotSize) ? void 0 : _context_shotSize.width) || imageWidth,
312
+ imageHeight: (null == (_context_shotSize1 = context.shotSize) ? void 0 : _context_shotSize1.height) || imageHeight,
313
+ taskId: currentTaskId
314
+ }, contextScreenshot));
315
+ insightOnTop = true;
316
+ });
317
+ }
318
+ const planningTask = task;
319
+ if (planningTask.recorder && planningTask.recorder.length > 0) {
320
+ var _planningTask_recorder_, _task_uiContext_shotSize, _task_uiContext, _task_uiContext_shotSize1, _task_uiContext1;
321
+ const screenshot = null == (_planningTask_recorder_ = planningTask.recorder[0]) ? void 0 : _planningTask_recorder_.screenshot;
322
+ scripts.push(createScript({
323
+ type: 'img',
324
+ duration: stillDuration,
325
+ title: typeStr(task),
326
+ subTitle: paramStr(task),
327
+ imageWidth: (null == (_task_uiContext = task.uiContext) ? void 0 : null == (_task_uiContext_shotSize = _task_uiContext.shotSize) ? void 0 : _task_uiContext_shotSize.width) || imageWidth,
328
+ imageHeight: (null == (_task_uiContext1 = task.uiContext) ? void 0 : null == (_task_uiContext_shotSize1 = _task_uiContext1.shotSize) ? void 0 : _task_uiContext_shotSize1.height) || imageHeight,
329
+ taskId: currentTaskId
330
+ }, asScreenshot(screenshot)));
331
+ }
332
+ } else if ('Action Space' === task.type) {
333
+ var _task_recorder_, _task_recorder;
334
+ const title = typeStr(task);
335
+ const subTitle = paramStr(task);
336
+ scripts.push({
337
+ type: 'spinning-pointer',
338
+ duration: actionSpinningPointerDuration,
339
+ title,
340
+ subTitle,
341
+ taskId: currentTaskId
342
+ });
343
+ if (insightOnTop) {
344
+ scripts.push({
345
+ type: 'clear-insight',
346
+ duration: clearInsightDuration,
347
+ title,
348
+ subTitle,
349
+ taskId: currentTaskId
350
+ });
351
+ insightOnTop = false;
352
+ }
353
+ scripts.push(setPointerScript(mousePointer, title, subTitle, currentTaskId));
354
+ const screenshot = null == (_task_recorder = task.recorder) ? void 0 : null == (_task_recorder_ = _task_recorder[0]) ? void 0 : _task_recorder_.screenshot;
355
+ const { width, height } = resolveTaskShotSize(task, imageWidth, imageHeight);
356
+ scripts.push(createScript({
357
+ type: 'img',
358
+ duration: actionDuration,
359
+ camera: 'Sleep' === task.subType ? createFullPageCameraState(width, height) : void 0,
360
+ title,
361
+ subTitle,
362
+ imageWidth: width,
363
+ imageHeight: height,
364
+ taskId: currentTaskId
365
+ }, asScreenshot(screenshot)));
366
+ } else {
367
+ var _task_recorder_1, _task_recorder1;
368
+ const title = typeStr(task);
369
+ const subTitle = paramStr(task);
370
+ const screenshot = null == (_task_recorder1 = task.recorder) ? void 0 : null == (_task_recorder_1 = _task_recorder1[task.recorder.length - 1]) ? void 0 : _task_recorder_1.screenshot;
371
+ if (screenshot) {
372
+ const { width, height } = resolveTaskShotSize(task, imageWidth, imageHeight);
373
+ scripts.push(createScript({
374
+ type: 'img',
375
+ duration: stillDuration,
376
+ camera: createFullPageCameraState(width, height),
377
+ title,
378
+ subTitle,
379
+ imageWidth: width,
380
+ imageHeight: height,
381
+ taskId: currentTaskId
382
+ }, asScreenshot(screenshot)));
383
+ }
384
+ }
385
+ if ('finished' !== task.status) {
386
+ var _task_recorder_2, _task_recorder2;
387
+ const errorTitle = typeStr(task);
388
+ const errorMsg = task.errorMessage || 'unknown error';
389
+ const errorSubTitle = errorMsg.indexOf('NOT_IMPLEMENTED_AS_DESIGNED') > 0 ? 'Further actions cannot be performed in the current environment' : errorMsg;
390
+ const screenshot = null == (_task_recorder2 = task.recorder) ? void 0 : null == (_task_recorder_2 = _task_recorder2[task.recorder.length - 1]) ? void 0 : _task_recorder_2.screenshot;
391
+ const { width, height } = resolveTaskShotSize(task, imageWidth, imageHeight);
392
+ scripts.push(createScript({
393
+ type: 'img',
394
+ camera: createFullPageCameraState(width, height),
395
+ duration: stillDuration,
396
+ title: errorTitle,
397
+ subTitle: errorSubTitle,
398
+ imageWidth: width,
399
+ imageHeight: height,
400
+ taskId: currentTaskId
401
+ }, asScreenshot(screenshot)));
402
+ }
403
+ });
404
+ if (insightOnTop) {
405
+ scripts.push({
406
+ type: 'clear-insight',
407
+ duration: clearInsightDuration,
408
+ title: '',
409
+ subTitle: '',
410
+ taskId: lastTaskId
411
+ });
412
+ insightOnTop = false;
413
+ }
414
+ const lastTaskShotSize = tasksIncluded.length > 0 ? resolveTaskShotSize(tasksIncluded[tasksIncluded.length - 1], imageWidth, imageHeight) : {
415
+ width: imageWidth,
416
+ height: imageHeight
417
+ };
418
+ scripts.push({
419
+ title: 'End',
420
+ subTitle: initSubTitle,
421
+ type: 'img',
422
+ duration: lastFrameDuration,
423
+ camera: createFullPageCameraState(lastTaskShotSize.width, lastTaskShotSize.height),
424
+ taskId: void 0
425
+ });
426
+ return scripts;
427
+ };
428
+ export { allScriptsFromDump, cameraStateForRect, extractDumpMetaInfo, generateAnimationScripts, mergeTwoCameraState };
@@ -0,0 +1,84 @@
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
+ formatBlackboardHighlightSummary: ()=>formatBlackboardHighlightSummary,
28
+ normalizeBlackboardHighlights: ()=>normalizeBlackboardHighlights
29
+ });
30
+ function formatCenterKey(center) {
31
+ return `${center[0]}:${center[1]}`;
32
+ }
33
+ function formatRectKey(rect) {
34
+ return `${rect.left}:${rect.top}:${rect.width}:${rect.height}`;
35
+ }
36
+ function getElementLabel(element) {
37
+ if ('content' in element && element.content) return element.content;
38
+ if ("description" in element && element.description) return element.description;
39
+ }
40
+ function normalizeBlackboardHighlights(elements) {
41
+ if (!(null == elements ? void 0 : elements.length)) return [];
42
+ const deduped = new Map();
43
+ elements.forEach((element, index)=>{
44
+ if (!(null == element ? void 0 : element.rect) || !(null == element ? void 0 : element.center)) return;
45
+ const label = getElementLabel(element);
46
+ const dedupeKey = [
47
+ 'id' in element ? element.id : '',
48
+ label || '',
49
+ formatCenterKey(element.center),
50
+ formatRectKey(element.rect)
51
+ ].join('|');
52
+ if (!deduped.has(dedupeKey)) deduped.set(dedupeKey, {
53
+ key: 'id' in element && element.id || `${dedupeKey || 'highlight'}-${index}`,
54
+ label,
55
+ center: element.center,
56
+ rect: element.rect
57
+ });
58
+ });
59
+ return Array.from(deduped.values());
60
+ }
61
+ function roundRect(rect) {
62
+ return {
63
+ left: Math.round(rect.left),
64
+ top: Math.round(rect.top),
65
+ width: Math.round(rect.width),
66
+ height: Math.round(rect.height)
67
+ };
68
+ }
69
+ function formatBlackboardHighlightSummary(highlight) {
70
+ const center = `[${Math.round(highlight.center[0])}, ${Math.round(highlight.center[1])}]`;
71
+ const rect = roundRect(highlight.rect);
72
+ const rectText = `rect=${JSON.stringify(rect)}`;
73
+ if (highlight.label) return `${highlight.label} center=${center}, ${rectText}`;
74
+ return `center=${center}, ${rectText}`;
75
+ }
76
+ exports.formatBlackboardHighlightSummary = __webpack_exports__.formatBlackboardHighlightSummary;
77
+ exports.normalizeBlackboardHighlights = __webpack_exports__.normalizeBlackboardHighlights;
78
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
79
+ "formatBlackboardHighlightSummary",
80
+ "normalizeBlackboardHighlights"
81
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
82
+ Object.defineProperty(exports, '__esModule', {
83
+ value: true
84
+ });