@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ ## Documentation
2
+
3
+ An AI-powered automation SDK can control the page, perform assertions, and extract data in JSON format using natural language.
4
+
5
+ See https://midscenejs.com/ for details.
6
+
7
+ ## License
8
+
9
+ Midscene is MIT licensed.
@@ -0,0 +1,47 @@
1
+ function formatCenterKey(center) {
2
+ return `${center[0]}:${center[1]}`;
3
+ }
4
+ function formatRectKey(rect) {
5
+ return `${rect.left}:${rect.top}:${rect.width}:${rect.height}`;
6
+ }
7
+ function getElementLabel(element) {
8
+ if ('content' in element && element.content) return element.content;
9
+ if ("description" in element && element.description) return element.description;
10
+ }
11
+ function normalizeBlackboardHighlights(elements) {
12
+ if (!(null == elements ? void 0 : elements.length)) return [];
13
+ const deduped = new Map();
14
+ elements.forEach((element, index)=>{
15
+ if (!(null == element ? void 0 : element.rect) || !(null == element ? void 0 : element.center)) return;
16
+ const label = getElementLabel(element);
17
+ const dedupeKey = [
18
+ 'id' in element ? element.id : '',
19
+ label || '',
20
+ formatCenterKey(element.center),
21
+ formatRectKey(element.rect)
22
+ ].join('|');
23
+ if (!deduped.has(dedupeKey)) deduped.set(dedupeKey, {
24
+ key: 'id' in element && element.id || `${dedupeKey || 'highlight'}-${index}`,
25
+ label,
26
+ center: element.center,
27
+ rect: element.rect
28
+ });
29
+ });
30
+ return Array.from(deduped.values());
31
+ }
32
+ function roundRect(rect) {
33
+ return {
34
+ left: Math.round(rect.left),
35
+ top: Math.round(rect.top),
36
+ width: Math.round(rect.width),
37
+ height: Math.round(rect.height)
38
+ };
39
+ }
40
+ function formatBlackboardHighlightSummary(highlight) {
41
+ const center = `[${Math.round(highlight.center[0])}, ${Math.round(highlight.center[1])}]`;
42
+ const rect = roundRect(highlight.rect);
43
+ const rectText = `rect=${JSON.stringify(rect)}`;
44
+ if (highlight.label) return `${highlight.label} center=${center}, ${rectText}`;
45
+ return `center=${center}, ${rectText}`;
46
+ }
47
+ export { formatBlackboardHighlightSummary, normalizeBlackboardHighlights };
@@ -0,0 +1,118 @@
1
+ .blackboard .footer {
2
+ color: #aaa;
3
+ }
4
+
5
+ .blackboard ul {
6
+ padding-left: 0;
7
+ }
8
+
9
+ .blackboard li {
10
+ list-style: none;
11
+ }
12
+
13
+ .blackboard .bottom-tip {
14
+ height: 30px;
15
+ }
16
+
17
+ .blackboard .bottom-tip-item {
18
+ color: #aaa;
19
+ text-overflow: ellipsis;
20
+ word-wrap: break-word;
21
+ max-width: 500px;
22
+ }
23
+
24
+ .blackboard-main-content {
25
+ position: relative;
26
+ overflow: hidden;
27
+ }
28
+
29
+ .blackboard-screenshot {
30
+ box-sizing: border-box;
31
+ border: 1px solid #888;
32
+ width: 100%;
33
+ display: block;
34
+ }
35
+
36
+ .blackboard-overlay {
37
+ pointer-events: none;
38
+ width: 100%;
39
+ position: absolute;
40
+ top: 0;
41
+ left: 0;
42
+ }
43
+
44
+ .blackboard-rect {
45
+ box-sizing: content-box;
46
+ pointer-events: none;
47
+ z-index: 1;
48
+ position: absolute;
49
+ }
50
+
51
+ .blackboard-rect-label {
52
+ white-space: nowrap;
53
+ padding: 1px 4px;
54
+ font-size: 14px;
55
+ font-weight: 600;
56
+ line-height: 1.4;
57
+ position: absolute;
58
+ bottom: 100%;
59
+ left: 0;
60
+ }
61
+
62
+ .blackboard-rect-search {
63
+ border: calc(1px * var(--ui-scale, 1)) solid #028391;
64
+ background: rgba(2, 131, 145, .15);
65
+ }
66
+
67
+ .blackboard-rect-search .blackboard-rect-label {
68
+ color: #028391;
69
+ }
70
+
71
+ .blackboard-rect-highlight {
72
+ border: calc(1px * var(--ui-scale, 1)) solid #fd5907;
73
+ background: rgba(253, 89, 7, .15);
74
+ animation: 1.2s ease-in-out infinite blackboard-pulse;
75
+ }
76
+
77
+ .blackboard-rect-highlight .blackboard-rect-label {
78
+ color: #000;
79
+ }
80
+
81
+ .blackboard-point {
82
+ width: calc(20px * var(--ui-scale, 1));
83
+ height: calc(20px * var(--ui-scale, 1));
84
+ margin-left: calc(-10px * var(--ui-scale, 1));
85
+ margin-top: calc(-10px * var(--ui-scale, 1));
86
+ border: calc(2px * var(--ui-scale, 1)) solid #fd5907;
87
+ box-shadow: 0 0 calc(6px * var(--ui-scale, 1)) rgba(253, 89, 7, .5);
88
+ pointer-events: none;
89
+ z-index: 2;
90
+ background: rgba(253, 89, 7, .4);
91
+ border-radius: 50%;
92
+ animation: 1.2s ease-in-out infinite blackboard-pulse;
93
+ position: absolute;
94
+ }
95
+
96
+ @keyframes blackboard-pulse {
97
+ 0%, 100% {
98
+ opacity: .4;
99
+ }
100
+
101
+ 50% {
102
+ opacity: 1;
103
+ box-shadow: 0 0 12px rgba(253, 89, 7, .5);
104
+ }
105
+ }
106
+
107
+ [data-theme="dark"] .blackboard .footer, [data-theme="dark"] .blackboard .bottom-tip-item {
108
+ color: rgba(255, 255, 255, .45);
109
+ }
110
+
111
+ [data-theme="dark"] .blackboard-screenshot {
112
+ border-color: rgba(255, 255, 255, .12);
113
+ }
114
+
115
+ [data-theme="dark"] .blackboard-rect-highlight .blackboard-rect-label {
116
+ color: #fff;
117
+ }
118
+
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import react from "react";
4
+ import { getCenterHighlightBox } from "../../utils/highlight-element.mjs";
5
+ import { normalizeBlackboardHighlights } from "./highlights.mjs";
6
+ import "./index.css";
7
+ const Blackboard = (props)=>{
8
+ var _props_uiContext;
9
+ const highlightElements = props.highlightElements || [];
10
+ const highlightRect = props.highlightRect;
11
+ if (!(null == (_props_uiContext = props.uiContext) ? void 0 : _props_uiContext.shotSize)) return /*#__PURE__*/ jsx("div", {
12
+ className: "blackboard",
13
+ children: /*#__PURE__*/ jsx("div", {
14
+ className: "blackboard-main-content",
15
+ style: {
16
+ padding: '20px'
17
+ },
18
+ children: "No UI context available"
19
+ })
20
+ });
21
+ const context = props.uiContext;
22
+ const { shotSize, screenshot } = context;
23
+ const screenWidth = shotSize.width;
24
+ const screenHeight = shotSize.height;
25
+ const highlightOverlays = react.useMemo(()=>normalizeBlackboardHighlights(highlightElements), [
26
+ highlightElements
27
+ ]);
28
+ const screenshotBase64 = react.useMemo(()=>{
29
+ if (!screenshot) return '';
30
+ if ('object' == typeof screenshot && 'base64' in screenshot) return screenshot.base64;
31
+ if ('string' == typeof screenshot) return screenshot;
32
+ return '';
33
+ }, [
34
+ screenshot
35
+ ]);
36
+ const highlightBoxes = highlightOverlays.map((highlight)=>getCenterHighlightBox(highlight));
37
+ let bottomTipA = null;
38
+ if (1 === highlightBoxes.length) bottomTipA = /*#__PURE__*/ jsx("div", {
39
+ className: "bottom-tip",
40
+ children: /*#__PURE__*/ jsxs("div", {
41
+ className: "bottom-tip-item",
42
+ children: [
43
+ "Element: ",
44
+ JSON.stringify(highlightBoxes[0])
45
+ ]
46
+ })
47
+ });
48
+ else if (highlightBoxes.length > 1) bottomTipA = /*#__PURE__*/ jsx("div", {
49
+ className: "bottom-tip",
50
+ children: /*#__PURE__*/ jsxs("div", {
51
+ className: "bottom-tip-item",
52
+ children: [
53
+ "Element: ",
54
+ JSON.stringify(highlightBoxes)
55
+ ]
56
+ })
57
+ });
58
+ return /*#__PURE__*/ jsxs("div", {
59
+ className: "blackboard",
60
+ children: [
61
+ /*#__PURE__*/ jsxs("div", {
62
+ className: "blackboard-main-content",
63
+ style: {
64
+ width: 'fit-content',
65
+ maxWidth: '100%',
66
+ position: 'relative'
67
+ },
68
+ children: [
69
+ screenshotBase64 && /*#__PURE__*/ jsx("img", {
70
+ src: screenshotBase64,
71
+ alt: "screenshot",
72
+ className: "blackboard-screenshot",
73
+ draggable: false
74
+ }),
75
+ /*#__PURE__*/ jsxs("div", {
76
+ className: "blackboard-overlay",
77
+ style: {
78
+ aspectRatio: `${screenWidth}/${screenHeight}`,
79
+ '--ui-scale': Math.max(1, Math.sqrt(screenWidth / 1920))
80
+ },
81
+ children: [
82
+ highlightRect && /*#__PURE__*/ jsx("div", {
83
+ className: "blackboard-rect blackboard-rect-search",
84
+ style: {
85
+ left: `${highlightRect.left / screenWidth * 100}%`,
86
+ top: `${highlightRect.top / screenHeight * 100}%`,
87
+ width: `${highlightRect.width / screenWidth * 100}%`,
88
+ height: `${highlightRect.height / screenHeight * 100}%`
89
+ },
90
+ children: /*#__PURE__*/ jsx("span", {
91
+ className: "blackboard-rect-label",
92
+ children: "Search Area"
93
+ })
94
+ }),
95
+ highlightOverlays.map((el)=>{
96
+ const highlightBox = getCenterHighlightBox(el);
97
+ return /*#__PURE__*/ jsx("div", {
98
+ className: "blackboard-rect blackboard-rect-highlight",
99
+ style: {
100
+ left: `${highlightBox.left / screenWidth * 100}%`,
101
+ top: `${highlightBox.top / screenHeight * 100}%`,
102
+ width: `${highlightBox.width / screenWidth * 100}%`,
103
+ height: `${highlightBox.height / screenHeight * 100}%`
104
+ }
105
+ }, `${el.key}-rect`);
106
+ })
107
+ ]
108
+ })
109
+ ]
110
+ }),
111
+ /*#__PURE__*/ jsx("div", {
112
+ className: "bottom-tip",
113
+ style: {
114
+ display: props.hideController ? 'none' : 'block'
115
+ },
116
+ children: bottomTipA
117
+ })
118
+ ]
119
+ });
120
+ };
121
+ const blackboard = Blackboard;
122
+ export { Blackboard, blackboard as default };
@@ -0,0 +1,251 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Checkbox, Dropdown, Radio, Tooltip } from "antd";
3
+ import setting from "../../icons/setting.mjs";
4
+ import { useEnvConfig } from "../../store/store.mjs";
5
+ import { alwaysRefreshScreenInfoTip, autoDismissKeyboardTip, deepLocateTip, deepThinkTip, domIncludedTip, imeStrategyTip, keyboardDismissStrategyTip, screenshotIncludedTip, trackingTip } from "../../utils/constants.mjs";
6
+ import { getDeviceCapabilities, hasDeviceSpecificConfig } from "../../utils/device-capabilities.mjs";
7
+ const ConfigSelector = ({ showDeepLocateOption = false, showDeepThinkOption = false, enableTracking = false, showDataExtractionOptions = false, hideDomAndScreenshotOptions = false, deviceType, trigger, popupPlacement = 'bottomRight' })=>{
8
+ const forceSameTabNavigation = useEnvConfig((state)=>state.forceSameTabNavigation);
9
+ const setForceSameTabNavigation = useEnvConfig((state)=>state.setForceSameTabNavigation);
10
+ const deepLocate = useEnvConfig((state)=>state.deepLocate);
11
+ const setDeepLocate = useEnvConfig((state)=>state.setDeepLocate);
12
+ const deepThink = useEnvConfig((state)=>state.deepThink);
13
+ const setDeepThink = useEnvConfig((state)=>state.setDeepThink);
14
+ const screenshotIncluded = useEnvConfig((state)=>state.screenshotIncluded);
15
+ const setScreenshotIncluded = useEnvConfig((state)=>state.setScreenshotIncluded);
16
+ const domIncluded = useEnvConfig((state)=>state.domIncluded);
17
+ const setDomIncluded = useEnvConfig((state)=>state.setDomIncluded);
18
+ const imeStrategy = useEnvConfig((state)=>state.imeStrategy);
19
+ const setImeStrategy = useEnvConfig((state)=>state.setImeStrategy);
20
+ const autoDismissKeyboard = useEnvConfig((state)=>state.autoDismissKeyboard);
21
+ const setAutoDismissKeyboard = useEnvConfig((state)=>state.setAutoDismissKeyboard);
22
+ const keyboardDismissStrategy = useEnvConfig((state)=>state.keyboardDismissStrategy);
23
+ const setKeyboardDismissStrategy = useEnvConfig((state)=>state.setKeyboardDismissStrategy);
24
+ const alwaysRefreshScreenInfo = useEnvConfig((state)=>state.alwaysRefreshScreenInfo);
25
+ const setAlwaysRefreshScreenInfo = useEnvConfig((state)=>state.setAlwaysRefreshScreenInfo);
26
+ const deviceCapabilities = getDeviceCapabilities(deviceType);
27
+ const hasDeviceOptions = hasDeviceSpecificConfig(deviceType);
28
+ if (!enableTracking && !showDeepLocateOption && !showDeepThinkOption && !showDataExtractionOptions && !hasDeviceOptions) return null;
29
+ const configItems = buildConfigItems();
30
+ return /*#__PURE__*/ jsx("div", {
31
+ className: "selector-trigger",
32
+ children: /*#__PURE__*/ jsx(Dropdown, {
33
+ getPopupContainer: (triggerNode)=>triggerNode.ownerDocument.body,
34
+ menu: {
35
+ items: configItems
36
+ },
37
+ overlayClassName: "config-selector-dropdown",
38
+ overlayStyle: {
39
+ zIndex: 10010
40
+ },
41
+ placement: popupPlacement,
42
+ trigger: [
43
+ 'click'
44
+ ],
45
+ children: null != trigger ? trigger : /*#__PURE__*/ jsx(setting, {
46
+ width: 24,
47
+ height: 24
48
+ })
49
+ })
50
+ });
51
+ function buildConfigItems() {
52
+ const items = [];
53
+ if (enableTracking) items.push({
54
+ label: /*#__PURE__*/ jsx(Checkbox, {
55
+ onChange: (e)=>setForceSameTabNavigation(e.target.checked),
56
+ checked: forceSameTabNavigation,
57
+ children: trackingTip
58
+ }),
59
+ key: 'track-config'
60
+ });
61
+ if (showDeepLocateOption) items.push({
62
+ label: /*#__PURE__*/ jsx(Checkbox, {
63
+ onChange: (e)=>{
64
+ setDeepLocate(e.target.checked);
65
+ },
66
+ checked: deepLocate,
67
+ children: deepLocateTip
68
+ }),
69
+ key: 'deep-locate-config'
70
+ });
71
+ if (showDeepThinkOption) items.push({
72
+ label: /*#__PURE__*/ jsxs("div", {
73
+ style: {
74
+ padding: '4px 0'
75
+ },
76
+ children: [
77
+ /*#__PURE__*/ jsx("div", {
78
+ style: {
79
+ marginBottom: '4px',
80
+ fontSize: '14px'
81
+ },
82
+ children: deepThinkTip
83
+ }),
84
+ /*#__PURE__*/ jsxs(Radio.Group, {
85
+ size: "small",
86
+ value: deepThink,
87
+ onChange: (e)=>setDeepThink(e.target.value),
88
+ children: [
89
+ /*#__PURE__*/ jsx(Tooltip, {
90
+ title: "Controlled by MIDSCENE_MODEL_REASONING_ENABLED env variable",
91
+ children: /*#__PURE__*/ jsx(Radio, {
92
+ value: 'unset',
93
+ children: "Auto"
94
+ })
95
+ }),
96
+ /*#__PURE__*/ jsx(Radio, {
97
+ value: true,
98
+ children: "On"
99
+ }),
100
+ /*#__PURE__*/ jsx(Radio, {
101
+ value: false,
102
+ children: "Off"
103
+ })
104
+ ]
105
+ })
106
+ ]
107
+ }),
108
+ key: 'deep-think-config'
109
+ });
110
+ if (showDataExtractionOptions && !hideDomAndScreenshotOptions) {
111
+ items.push({
112
+ label: /*#__PURE__*/ jsx(Checkbox, {
113
+ onChange: (e)=>{
114
+ setScreenshotIncluded(e.target.checked);
115
+ },
116
+ checked: screenshotIncluded,
117
+ children: screenshotIncludedTip
118
+ }),
119
+ key: 'screenshot-included-config'
120
+ });
121
+ items.push({
122
+ label: /*#__PURE__*/ jsxs("div", {
123
+ style: {
124
+ padding: '4px 0'
125
+ },
126
+ children: [
127
+ /*#__PURE__*/ jsx("div", {
128
+ style: {
129
+ marginBottom: '4px',
130
+ fontSize: '14px'
131
+ },
132
+ children: domIncludedTip
133
+ }),
134
+ /*#__PURE__*/ jsxs(Radio.Group, {
135
+ size: "small",
136
+ value: domIncluded,
137
+ onChange: (e)=>setDomIncluded(e.target.value),
138
+ children: [
139
+ /*#__PURE__*/ jsx(Radio, {
140
+ value: false,
141
+ children: "Off"
142
+ }),
143
+ /*#__PURE__*/ jsx(Radio, {
144
+ value: true,
145
+ children: "All"
146
+ }),
147
+ /*#__PURE__*/ jsx(Radio, {
148
+ value: 'visible-only',
149
+ children: "Visible only"
150
+ })
151
+ ]
152
+ })
153
+ ]
154
+ }),
155
+ key: 'dom-included-config'
156
+ });
157
+ }
158
+ if (deviceCapabilities.supportsImeStrategy) {
159
+ items.push({
160
+ label: /*#__PURE__*/ jsxs("div", {
161
+ style: {
162
+ padding: '4px 0'
163
+ },
164
+ children: [
165
+ /*#__PURE__*/ jsx("div", {
166
+ style: {
167
+ marginBottom: '4px',
168
+ fontSize: '14px'
169
+ },
170
+ children: imeStrategyTip
171
+ }),
172
+ /*#__PURE__*/ jsxs(Radio.Group, {
173
+ size: "small",
174
+ value: imeStrategy,
175
+ onChange: (e)=>setImeStrategy(e.target.value),
176
+ children: [
177
+ /*#__PURE__*/ jsx(Radio, {
178
+ value: "always-yadb",
179
+ children: "Always YADB"
180
+ }),
181
+ /*#__PURE__*/ jsx(Radio, {
182
+ value: "yadb-for-non-ascii",
183
+ children: "YADB for non-ASCII"
184
+ })
185
+ ]
186
+ })
187
+ ]
188
+ }),
189
+ key: 'ime-strategy-config'
190
+ });
191
+ if (deviceCapabilities.supportsAutoDismissKeyboard) items.push({
192
+ label: /*#__PURE__*/ jsx(Checkbox, {
193
+ onChange: (e)=>setAutoDismissKeyboard(e.target.checked),
194
+ checked: autoDismissKeyboard,
195
+ children: autoDismissKeyboardTip
196
+ }),
197
+ key: 'auto-dismiss-keyboard-config'
198
+ });
199
+ if (deviceCapabilities.supportsKeyboardDismissStrategy) items.push({
200
+ label: /*#__PURE__*/ jsxs("div", {
201
+ style: {
202
+ padding: '4px 0'
203
+ },
204
+ children: [
205
+ /*#__PURE__*/ jsx("div", {
206
+ style: {
207
+ marginBottom: '4px',
208
+ fontSize: '14px'
209
+ },
210
+ children: keyboardDismissStrategyTip
211
+ }),
212
+ /*#__PURE__*/ jsxs(Radio.Group, {
213
+ size: "small",
214
+ value: keyboardDismissStrategy,
215
+ onChange: (e)=>setKeyboardDismissStrategy(e.target.value),
216
+ children: [
217
+ /*#__PURE__*/ jsx(Radio, {
218
+ value: "esc-first",
219
+ children: "ESC first"
220
+ }),
221
+ /*#__PURE__*/ jsx(Radio, {
222
+ value: "back-first",
223
+ children: "Back first"
224
+ })
225
+ ]
226
+ })
227
+ ]
228
+ }),
229
+ key: 'keyboard-dismiss-strategy-config'
230
+ });
231
+ if (deviceCapabilities.supportsAlwaysRefreshScreenInfo) items.push({
232
+ label: /*#__PURE__*/ jsx(Checkbox, {
233
+ onChange: (e)=>setAlwaysRefreshScreenInfo(e.target.checked),
234
+ checked: alwaysRefreshScreenInfo,
235
+ children: alwaysRefreshScreenInfoTip
236
+ }),
237
+ key: 'always-refresh-screen-info-config'
238
+ });
239
+ }
240
+ if (!deviceCapabilities.supportsImeStrategy && deviceCapabilities.supportsAutoDismissKeyboard) items.push({
241
+ label: /*#__PURE__*/ jsx(Checkbox, {
242
+ onChange: (e)=>setAutoDismissKeyboard(e.target.checked),
243
+ checked: autoDismissKeyboard,
244
+ children: autoDismissKeyboardTip
245
+ }),
246
+ key: 'auto-dismiss-keyboard-config'
247
+ });
248
+ return items;
249
+ }
250
+ };
251
+ export { ConfigSelector };
@@ -0,0 +1,37 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button } from "antd";
3
+ import blackboard from "../blackboard/index.mjs";
4
+ import { iconForStatus } from "../misc/index.mjs";
5
+ import playground_demo_ui_context from "../playground/playground-demo-ui-context.json";
6
+ const ContextPreview = ({ uiContextPreview, setUiContextPreview, showContextPreview })=>{
7
+ if (!showContextPreview) return null;
8
+ return /*#__PURE__*/ jsxs("div", {
9
+ className: "form-part context-panel",
10
+ children: [
11
+ /*#__PURE__*/ jsx("h3", {
12
+ children: "UI Context"
13
+ }),
14
+ uiContextPreview ? /*#__PURE__*/ jsx(blackboard, {
15
+ uiContext: uiContextPreview,
16
+ hideController: true
17
+ }) : /*#__PURE__*/ jsxs("div", {
18
+ children: [
19
+ iconForStatus('failed'),
20
+ " No UI context",
21
+ /*#__PURE__*/ jsx(Button, {
22
+ type: "link",
23
+ onClick: (e)=>{
24
+ e.preventDefault();
25
+ setUiContextPreview(playground_demo_ui_context);
26
+ },
27
+ children: "Load Demo"
28
+ }),
29
+ /*#__PURE__*/ jsx("div", {
30
+ children: "To load the UI context, you can either use the demo data above, or click the 'Send to Playground' in the report page."
31
+ })
32
+ ]
33
+ })
34
+ ]
35
+ });
36
+ };
37
+ export { ContextPreview };