@midscene/visualizer 0.26.7-beta-20250818081955.0 → 0.26.7-beta-20250820150415.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/component/blackboard.mjs +20 -8
- package/dist/es/component/player.mjs +68 -4
- package/dist/es/component/store/store.mjs +24 -7
- package/dist/es/icons/show-marker.mjs +16 -0
- package/dist/es/index.mjs +1 -2
- package/dist/lib/component/blackboard.js +20 -8
- package/dist/lib/component/player.js +70 -4
- package/dist/lib/component/store/store.js +24 -7
- package/dist/lib/icons/show-marker.js +50 -0
- package/dist/lib/index.js +0 -4
- package/dist/types/component/store/store.d.ts +5 -3
- package/dist/types/index.d.ts +0 -1
- package/package.json +4 -4
- package/dist/es/component/describer.mjs +0 -128
- package/dist/lib/component/describer.js +0 -165
- package/dist/types/component/describer.d.ts +0 -6
|
@@ -75,7 +75,7 @@ const Blackboard = (props)=>{
|
|
|
75
75
|
const elementMarkContainer = useMemo(()=>new Container(), []);
|
|
76
76
|
const [hoverElement, setHoverElement] = useState(null);
|
|
77
77
|
const pixiBgRef = useRef(void 0);
|
|
78
|
-
const {
|
|
78
|
+
const { backgroundVisible, setBackgroundVisible, elementsVisible, setElementsVisible } = useBlackboardPreference();
|
|
79
79
|
useEffect(()=>{
|
|
80
80
|
Promise.resolve((async ()=>{
|
|
81
81
|
if (!domRef.current || !screenWidth) return;
|
|
@@ -152,6 +152,7 @@ const Blackboard = (props)=>{
|
|
|
152
152
|
backgroundSprite.eventMode = 'passive';
|
|
153
153
|
app.stage.addChildAt(backgroundSprite, 0);
|
|
154
154
|
pixiBgRef.current = backgroundSprite;
|
|
155
|
+
backgroundSprite.visible = backgroundVisible;
|
|
155
156
|
};
|
|
156
157
|
img.onerror = (e)=>{
|
|
157
158
|
console.error('load screenshot failed', e);
|
|
@@ -203,8 +204,12 @@ const Blackboard = (props)=>{
|
|
|
203
204
|
highlightRect,
|
|
204
205
|
highlightPoints
|
|
205
206
|
]);
|
|
207
|
+
const onSetBackgroundVisible = (e)=>{
|
|
208
|
+
setBackgroundVisible(e.target.checked);
|
|
209
|
+
if (pixiBgRef.current) pixiBgRef.current.visible = e.target.checked;
|
|
210
|
+
};
|
|
206
211
|
const onSetElementsVisible = (e)=>{
|
|
207
|
-
|
|
212
|
+
setElementsVisible(e.target.checked);
|
|
208
213
|
elementMarkContainer.visible = e.target.checked;
|
|
209
214
|
};
|
|
210
215
|
let bottomTipA = null;
|
|
@@ -243,13 +248,20 @@ const Blackboard = (props)=>{
|
|
|
243
248
|
style: {
|
|
244
249
|
display: props.hideController ? 'none' : 'block'
|
|
245
250
|
},
|
|
246
|
-
children: /*#__PURE__*/
|
|
251
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
247
252
|
className: "overlay-control",
|
|
248
|
-
children:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
+
children: [
|
|
254
|
+
/*#__PURE__*/ jsx(Checkbox, {
|
|
255
|
+
checked: backgroundVisible,
|
|
256
|
+
onChange: onSetBackgroundVisible,
|
|
257
|
+
children: "Background"
|
|
258
|
+
}),
|
|
259
|
+
/*#__PURE__*/ jsx(Checkbox, {
|
|
260
|
+
checked: elementsVisible,
|
|
261
|
+
onChange: onSetElementsVisible,
|
|
262
|
+
children: "Elements"
|
|
263
|
+
})
|
|
264
|
+
]
|
|
253
265
|
})
|
|
254
266
|
}),
|
|
255
267
|
/*#__PURE__*/ jsx("div", {
|
|
@@ -9,8 +9,11 @@ import { CaretRightOutlined, DownloadOutlined, ExportOutlined, LoadingOutlined }
|
|
|
9
9
|
import { treeToList } from "@midscene/shared/extractor";
|
|
10
10
|
import { Dropdown, Spin, Switch, Tooltip } from "antd";
|
|
11
11
|
import global_perspective from "../icons/global-perspective.mjs";
|
|
12
|
+
import player_setting from "../icons/player-setting.mjs";
|
|
13
|
+
import show_marker from "../icons/show-marker.mjs";
|
|
12
14
|
import { rectMarkForItem } from "./blackboard.mjs";
|
|
13
15
|
import { getTextureFromCache, loadTexture } from "./pixi-loader.mjs";
|
|
16
|
+
import { useBlackboardPreference } from "./store/store.mjs";
|
|
14
17
|
function _define_property(obj, key, value) {
|
|
15
18
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
16
19
|
value: value,
|
|
@@ -116,11 +119,12 @@ function Player(props) {
|
|
|
116
119
|
var _scripts_;
|
|
117
120
|
const [titleText, setTitleText] = useState('');
|
|
118
121
|
const [subTitleText, setSubTitleText] = useState('');
|
|
119
|
-
const
|
|
122
|
+
const { autoZoom, setAutoZoom, elementsVisible, setElementsVisible } = useBlackboardPreference();
|
|
120
123
|
useEffect(()=>{
|
|
121
124
|
if ((null == props ? void 0 : props.autoZoom) !== void 0) setAutoZoom(props.autoZoom);
|
|
122
125
|
}, [
|
|
123
|
-
null == props ? void 0 : props.autoZoom
|
|
126
|
+
null == props ? void 0 : props.autoZoom,
|
|
127
|
+
setAutoZoom
|
|
124
128
|
]);
|
|
125
129
|
const scripts = null == props ? void 0 : props.replayScripts;
|
|
126
130
|
const imageWidth = (null == props ? void 0 : props.imageWidth) || 1920;
|
|
@@ -144,6 +148,12 @@ function Player(props) {
|
|
|
144
148
|
container.zIndex = LAYER_ORDER_INSIGHT;
|
|
145
149
|
return container;
|
|
146
150
|
}, []);
|
|
151
|
+
useEffect(()=>{
|
|
152
|
+
insightMarkContainer.visible = elementsVisible;
|
|
153
|
+
}, [
|
|
154
|
+
elementsVisible,
|
|
155
|
+
insightMarkContainer
|
|
156
|
+
]);
|
|
147
157
|
const basicCameraState = {
|
|
148
158
|
left: 0,
|
|
149
159
|
top: 0,
|
|
@@ -655,7 +665,8 @@ function Player(props) {
|
|
|
655
665
|
}),
|
|
656
666
|
/*#__PURE__*/ jsx(Dropdown, {
|
|
657
667
|
trigger: [
|
|
658
|
-
'hover'
|
|
668
|
+
'hover',
|
|
669
|
+
'click'
|
|
659
670
|
],
|
|
660
671
|
placement: "bottomRight",
|
|
661
672
|
overlayStyle: {
|
|
@@ -729,6 +740,59 @@ function Player(props) {
|
|
|
729
740
|
})
|
|
730
741
|
]
|
|
731
742
|
})
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
key: 'elementsVisible',
|
|
746
|
+
style: {
|
|
747
|
+
height: '39px',
|
|
748
|
+
margin: 0,
|
|
749
|
+
padding: '0 12px'
|
|
750
|
+
},
|
|
751
|
+
label: /*#__PURE__*/ jsxs("div", {
|
|
752
|
+
style: {
|
|
753
|
+
display: 'flex',
|
|
754
|
+
alignItems: 'center',
|
|
755
|
+
justifyContent: 'space-between',
|
|
756
|
+
width: '100%',
|
|
757
|
+
height: '39px'
|
|
758
|
+
},
|
|
759
|
+
children: [
|
|
760
|
+
/*#__PURE__*/ jsxs("div", {
|
|
761
|
+
style: {
|
|
762
|
+
display: 'flex',
|
|
763
|
+
alignItems: 'center',
|
|
764
|
+
gap: '4px'
|
|
765
|
+
},
|
|
766
|
+
children: [
|
|
767
|
+
/*#__PURE__*/ jsx(show_marker, {
|
|
768
|
+
style: {
|
|
769
|
+
width: '16px',
|
|
770
|
+
height: '16px'
|
|
771
|
+
}
|
|
772
|
+
}),
|
|
773
|
+
/*#__PURE__*/ jsx("span", {
|
|
774
|
+
style: {
|
|
775
|
+
fontSize: '12px',
|
|
776
|
+
marginRight: '16px'
|
|
777
|
+
},
|
|
778
|
+
children: "Show Element Markers"
|
|
779
|
+
})
|
|
780
|
+
]
|
|
781
|
+
}),
|
|
782
|
+
/*#__PURE__*/ jsx(Switch, {
|
|
783
|
+
size: "small",
|
|
784
|
+
checked: elementsVisible,
|
|
785
|
+
onChange: (checked)=>{
|
|
786
|
+
setElementsVisible(checked);
|
|
787
|
+
triggerReplay();
|
|
788
|
+
},
|
|
789
|
+
onClick: (_, e)=>{
|
|
790
|
+
var _e_stopPropagation;
|
|
791
|
+
return null == e ? void 0 : null == (_e_stopPropagation = e.stopPropagation) ? void 0 : _e_stopPropagation.call(e);
|
|
792
|
+
}
|
|
793
|
+
})
|
|
794
|
+
]
|
|
795
|
+
})
|
|
732
796
|
}
|
|
733
797
|
]
|
|
734
798
|
},
|
|
@@ -744,7 +808,7 @@ function Player(props) {
|
|
|
744
808
|
opacity: mouseOverSettingsIcon ? 1 : 0.7,
|
|
745
809
|
transition: 'opacity 0.2s'
|
|
746
810
|
},
|
|
747
|
-
children: /*#__PURE__*/ jsx(
|
|
811
|
+
children: /*#__PURE__*/ jsx(player_setting, {
|
|
748
812
|
style: {
|
|
749
813
|
width: '16px',
|
|
750
814
|
height: '16px'
|
|
@@ -27,20 +27,37 @@ __webpack_require__.d(external_zustand_namespaceObject, {
|
|
|
27
27
|
create: ()=>create
|
|
28
28
|
});
|
|
29
29
|
const { create: store_create } = external_zustand_namespaceObject;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const AUTO_ZOOM_KEY = 'midscene-auto-zoom';
|
|
31
|
+
const BACKGROUND_VISIBLE_KEY = 'midscene-background-visible';
|
|
32
|
+
const ELEMENTS_VISIBLE_KEY = 'midscene-elements-visible';
|
|
33
|
+
const useBlackboardPreference = store_create((set)=>{
|
|
34
|
+
const savedAutoZoom = 'false' !== localStorage.getItem(AUTO_ZOOM_KEY);
|
|
35
|
+
const savedBackgroundVisible = 'false' !== localStorage.getItem(BACKGROUND_VISIBLE_KEY);
|
|
36
|
+
const savedElementsVisible = 'false' !== localStorage.getItem(ELEMENTS_VISIBLE_KEY);
|
|
37
|
+
return {
|
|
38
|
+
backgroundVisible: savedBackgroundVisible,
|
|
39
|
+
elementsVisible: savedElementsVisible,
|
|
40
|
+
autoZoom: savedAutoZoom,
|
|
41
|
+
setBackgroundVisible: (visible)=>{
|
|
34
42
|
set({
|
|
35
|
-
|
|
43
|
+
backgroundVisible: visible
|
|
36
44
|
});
|
|
45
|
+
localStorage.setItem(BACKGROUND_VISIBLE_KEY, visible.toString());
|
|
37
46
|
},
|
|
38
|
-
|
|
47
|
+
setElementsVisible: (visible)=>{
|
|
39
48
|
set({
|
|
40
49
|
elementsVisible: visible
|
|
41
50
|
});
|
|
51
|
+
localStorage.setItem(ELEMENTS_VISIBLE_KEY, visible.toString());
|
|
52
|
+
},
|
|
53
|
+
setAutoZoom: (enabled)=>{
|
|
54
|
+
set({
|
|
55
|
+
autoZoom: enabled
|
|
56
|
+
});
|
|
57
|
+
localStorage.setItem(AUTO_ZOOM_KEY, enabled.toString());
|
|
42
58
|
}
|
|
43
|
-
}
|
|
59
|
+
};
|
|
60
|
+
});
|
|
44
61
|
const CONFIG_KEY = 'midscene-env-config';
|
|
45
62
|
const SERVICE_MODE_KEY = 'midscene-service-mode';
|
|
46
63
|
const TRACKING_ACTIVE_TAB_KEY = 'midscene-tracking-active-tab';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const SvgShowMarker = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
width: 16,
|
|
6
|
+
height: 16,
|
|
7
|
+
fill: "none",
|
|
8
|
+
viewBox: "0 0 16 16",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
11
|
+
fill: "#333",
|
|
12
|
+
d: "M13 1.835a2.165 2.165 0 0 1 .665 4.225v3.88a2.166 2.166 0 1 1-2.725 2.725H5.06a2.165 2.165 0 1 1-2.725-2.726V6.06A2.165 2.165 0 1 1 5.06 3.336h5.88c.281-.87 1.097-1.5 2.06-1.5m-10 9.33a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67m10 0a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67m-7.94-6.5A2.17 2.17 0 0 1 3.665 6.06v3.88c.66.213 1.181.734 1.395 1.395h5.88a2.17 2.17 0 0 1 1.395-1.396V6.06a2.17 2.17 0 0 1-1.395-1.394zM3 3.165a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67m10 0a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67"
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
const show_marker = SvgShowMarker;
|
|
16
|
+
export { show_marker as default };
|
package/dist/es/index.mjs
CHANGED
|
@@ -14,8 +14,7 @@ import { PromptInput } from "./component/playground/PromptInput.mjs";
|
|
|
14
14
|
import { Player } from "./component/player.mjs";
|
|
15
15
|
import { Blackboard } from "./component/blackboard.mjs";
|
|
16
16
|
import { GithubStar } from "./component/github-star.mjs";
|
|
17
|
-
import { Describer } from "./component/describer.mjs";
|
|
18
17
|
import { actionNameForType, blankResult, cancelTask, checkServerStatus, formatErrorMessage, getPlaceholderForType, getTaskProgress, overrideServerConfig, requestPlaygroundServer, staticAgentFromContext } from "./component/playground/playground-utils.mjs";
|
|
19
18
|
import { filterBase64Value, timeStr } from "./utils.mjs";
|
|
20
19
|
import shiny_text from "./component/shiny-text.mjs";
|
|
21
|
-
export { Blackboard, ContextPreview,
|
|
20
|
+
export { Blackboard, ContextPreview, EnvConfig, GithubStar, Logo, Player, PlaygroundResultView, PromptInput, ServiceModeControl, shiny_text as ShinyText, actionNameForType, allScriptsFromDump, blankResult, cancelTask, checkServerStatus, colorForName, filterBase64Value, formatErrorMessage, generateAnimationScripts, getPlaceholderForType, getTaskProgress, globalThemeConfig, highlightColorForType, iconForStatus, overrideServerConfig, requestPlaygroundServer, staticAgentFromContext, timeCostStrElement, timeStr, useEnvConfig, useServerValid, useStaticPageAgent };
|
|
@@ -106,7 +106,7 @@ const Blackboard = (props)=>{
|
|
|
106
106
|
const elementMarkContainer = (0, external_react_namespaceObject.useMemo)(()=>new external_pixi_js_namespaceObject.Container(), []);
|
|
107
107
|
const [hoverElement, setHoverElement] = (0, external_react_namespaceObject.useState)(null);
|
|
108
108
|
const pixiBgRef = (0, external_react_namespaceObject.useRef)(void 0);
|
|
109
|
-
const {
|
|
109
|
+
const { backgroundVisible, setBackgroundVisible, elementsVisible, setElementsVisible } = (0, store_js_namespaceObject.useBlackboardPreference)();
|
|
110
110
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
111
111
|
Promise.resolve((async ()=>{
|
|
112
112
|
if (!domRef.current || !screenWidth) return;
|
|
@@ -183,6 +183,7 @@ const Blackboard = (props)=>{
|
|
|
183
183
|
backgroundSprite.eventMode = 'passive';
|
|
184
184
|
app.stage.addChildAt(backgroundSprite, 0);
|
|
185
185
|
pixiBgRef.current = backgroundSprite;
|
|
186
|
+
backgroundSprite.visible = backgroundVisible;
|
|
186
187
|
};
|
|
187
188
|
img.onerror = (e)=>{
|
|
188
189
|
console.error('load screenshot failed', e);
|
|
@@ -234,8 +235,12 @@ const Blackboard = (props)=>{
|
|
|
234
235
|
highlightRect,
|
|
235
236
|
highlightPoints
|
|
236
237
|
]);
|
|
238
|
+
const onSetBackgroundVisible = (e)=>{
|
|
239
|
+
setBackgroundVisible(e.target.checked);
|
|
240
|
+
if (pixiBgRef.current) pixiBgRef.current.visible = e.target.checked;
|
|
241
|
+
};
|
|
237
242
|
const onSetElementsVisible = (e)=>{
|
|
238
|
-
|
|
243
|
+
setElementsVisible(e.target.checked);
|
|
239
244
|
elementMarkContainer.visible = e.target.checked;
|
|
240
245
|
};
|
|
241
246
|
let bottomTipA = null;
|
|
@@ -274,13 +279,20 @@ const Blackboard = (props)=>{
|
|
|
274
279
|
style: {
|
|
275
280
|
display: props.hideController ? 'none' : 'block'
|
|
276
281
|
},
|
|
277
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
282
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
278
283
|
className: "overlay-control",
|
|
279
|
-
children:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
children: [
|
|
285
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Checkbox, {
|
|
286
|
+
checked: backgroundVisible,
|
|
287
|
+
onChange: onSetBackgroundVisible,
|
|
288
|
+
children: "Background"
|
|
289
|
+
}),
|
|
290
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Checkbox, {
|
|
291
|
+
checked: elementsVisible,
|
|
292
|
+
onChange: onSetElementsVisible,
|
|
293
|
+
children: "Elements"
|
|
294
|
+
})
|
|
295
|
+
]
|
|
284
296
|
})
|
|
285
297
|
}),
|
|
286
298
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
@@ -47,8 +47,13 @@ const extractor_namespaceObject = require("@midscene/shared/extractor");
|
|
|
47
47
|
const external_antd_namespaceObject = require("antd");
|
|
48
48
|
const global_perspective_js_namespaceObject = require("../icons/global-perspective.js");
|
|
49
49
|
var global_perspective_js_default = /*#__PURE__*/ __webpack_require__.n(global_perspective_js_namespaceObject);
|
|
50
|
+
const player_setting_js_namespaceObject = require("../icons/player-setting.js");
|
|
51
|
+
var player_setting_js_default = /*#__PURE__*/ __webpack_require__.n(player_setting_js_namespaceObject);
|
|
52
|
+
const show_marker_js_namespaceObject = require("../icons/show-marker.js");
|
|
53
|
+
var show_marker_js_default = /*#__PURE__*/ __webpack_require__.n(show_marker_js_namespaceObject);
|
|
50
54
|
const external_blackboard_js_namespaceObject = require("./blackboard.js");
|
|
51
55
|
const external_pixi_loader_js_namespaceObject = require("./pixi-loader.js");
|
|
56
|
+
const store_js_namespaceObject = require("./store/store.js");
|
|
52
57
|
function _define_property(obj, key, value) {
|
|
53
58
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
54
59
|
value: value,
|
|
@@ -154,11 +159,12 @@ function Player(props) {
|
|
|
154
159
|
var _scripts_;
|
|
155
160
|
const [titleText, setTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
156
161
|
const [subTitleText, setSubTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
157
|
-
const
|
|
162
|
+
const { autoZoom, setAutoZoom, elementsVisible, setElementsVisible } = (0, store_js_namespaceObject.useBlackboardPreference)();
|
|
158
163
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
159
164
|
if ((null == props ? void 0 : props.autoZoom) !== void 0) setAutoZoom(props.autoZoom);
|
|
160
165
|
}, [
|
|
161
|
-
null == props ? void 0 : props.autoZoom
|
|
166
|
+
null == props ? void 0 : props.autoZoom,
|
|
167
|
+
setAutoZoom
|
|
162
168
|
]);
|
|
163
169
|
const scripts = null == props ? void 0 : props.replayScripts;
|
|
164
170
|
const imageWidth = (null == props ? void 0 : props.imageWidth) || 1920;
|
|
@@ -182,6 +188,12 @@ function Player(props) {
|
|
|
182
188
|
container.zIndex = LAYER_ORDER_INSIGHT;
|
|
183
189
|
return container;
|
|
184
190
|
}, []);
|
|
191
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
192
|
+
insightMarkContainer.visible = elementsVisible;
|
|
193
|
+
}, [
|
|
194
|
+
elementsVisible,
|
|
195
|
+
insightMarkContainer
|
|
196
|
+
]);
|
|
185
197
|
const basicCameraState = {
|
|
186
198
|
left: 0,
|
|
187
199
|
top: 0,
|
|
@@ -693,7 +705,8 @@ function Player(props) {
|
|
|
693
705
|
}),
|
|
694
706
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Dropdown, {
|
|
695
707
|
trigger: [
|
|
696
|
-
'hover'
|
|
708
|
+
'hover',
|
|
709
|
+
'click'
|
|
697
710
|
],
|
|
698
711
|
placement: "bottomRight",
|
|
699
712
|
overlayStyle: {
|
|
@@ -767,6 +780,59 @@ function Player(props) {
|
|
|
767
780
|
})
|
|
768
781
|
]
|
|
769
782
|
})
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
key: 'elementsVisible',
|
|
786
|
+
style: {
|
|
787
|
+
height: '39px',
|
|
788
|
+
margin: 0,
|
|
789
|
+
padding: '0 12px'
|
|
790
|
+
},
|
|
791
|
+
label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
792
|
+
style: {
|
|
793
|
+
display: 'flex',
|
|
794
|
+
alignItems: 'center',
|
|
795
|
+
justifyContent: 'space-between',
|
|
796
|
+
width: '100%',
|
|
797
|
+
height: '39px'
|
|
798
|
+
},
|
|
799
|
+
children: [
|
|
800
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
801
|
+
style: {
|
|
802
|
+
display: 'flex',
|
|
803
|
+
alignItems: 'center',
|
|
804
|
+
gap: '4px'
|
|
805
|
+
},
|
|
806
|
+
children: [
|
|
807
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(show_marker_js_default(), {
|
|
808
|
+
style: {
|
|
809
|
+
width: '16px',
|
|
810
|
+
height: '16px'
|
|
811
|
+
}
|
|
812
|
+
}),
|
|
813
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
814
|
+
style: {
|
|
815
|
+
fontSize: '12px',
|
|
816
|
+
marginRight: '16px'
|
|
817
|
+
},
|
|
818
|
+
children: "Show Element Markers"
|
|
819
|
+
})
|
|
820
|
+
]
|
|
821
|
+
}),
|
|
822
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Switch, {
|
|
823
|
+
size: "small",
|
|
824
|
+
checked: elementsVisible,
|
|
825
|
+
onChange: (checked)=>{
|
|
826
|
+
setElementsVisible(checked);
|
|
827
|
+
triggerReplay();
|
|
828
|
+
},
|
|
829
|
+
onClick: (_, e)=>{
|
|
830
|
+
var _e_stopPropagation;
|
|
831
|
+
return null == e ? void 0 : null == (_e_stopPropagation = e.stopPropagation) ? void 0 : _e_stopPropagation.call(e);
|
|
832
|
+
}
|
|
833
|
+
})
|
|
834
|
+
]
|
|
835
|
+
})
|
|
770
836
|
}
|
|
771
837
|
]
|
|
772
838
|
},
|
|
@@ -782,7 +848,7 @@ function Player(props) {
|
|
|
782
848
|
opacity: mouseOverSettingsIcon ? 1 : 0.7,
|
|
783
849
|
transition: 'opacity 0.2s'
|
|
784
850
|
},
|
|
785
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
851
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(player_setting_js_default(), {
|
|
786
852
|
style: {
|
|
787
853
|
width: '16px',
|
|
788
854
|
height: '16px'
|
|
@@ -29,20 +29,37 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
});
|
|
30
30
|
const external_zustand_namespaceObject = require("zustand");
|
|
31
31
|
const { create } = external_zustand_namespaceObject;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const AUTO_ZOOM_KEY = 'midscene-auto-zoom';
|
|
33
|
+
const BACKGROUND_VISIBLE_KEY = 'midscene-background-visible';
|
|
34
|
+
const ELEMENTS_VISIBLE_KEY = 'midscene-elements-visible';
|
|
35
|
+
const useBlackboardPreference = create((set)=>{
|
|
36
|
+
const savedAutoZoom = 'false' !== localStorage.getItem(AUTO_ZOOM_KEY);
|
|
37
|
+
const savedBackgroundVisible = 'false' !== localStorage.getItem(BACKGROUND_VISIBLE_KEY);
|
|
38
|
+
const savedElementsVisible = 'false' !== localStorage.getItem(ELEMENTS_VISIBLE_KEY);
|
|
39
|
+
return {
|
|
40
|
+
backgroundVisible: savedBackgroundVisible,
|
|
41
|
+
elementsVisible: savedElementsVisible,
|
|
42
|
+
autoZoom: savedAutoZoom,
|
|
43
|
+
setBackgroundVisible: (visible)=>{
|
|
36
44
|
set({
|
|
37
|
-
|
|
45
|
+
backgroundVisible: visible
|
|
38
46
|
});
|
|
47
|
+
localStorage.setItem(BACKGROUND_VISIBLE_KEY, visible.toString());
|
|
39
48
|
},
|
|
40
|
-
|
|
49
|
+
setElementsVisible: (visible)=>{
|
|
41
50
|
set({
|
|
42
51
|
elementsVisible: visible
|
|
43
52
|
});
|
|
53
|
+
localStorage.setItem(ELEMENTS_VISIBLE_KEY, visible.toString());
|
|
54
|
+
},
|
|
55
|
+
setAutoZoom: (enabled)=>{
|
|
56
|
+
set({
|
|
57
|
+
autoZoom: enabled
|
|
58
|
+
});
|
|
59
|
+
localStorage.setItem(AUTO_ZOOM_KEY, enabled.toString());
|
|
44
60
|
}
|
|
45
|
-
}
|
|
61
|
+
};
|
|
62
|
+
});
|
|
46
63
|
const CONFIG_KEY = 'midscene-env-config';
|
|
47
64
|
const SERVICE_MODE_KEY = 'midscene-service-mode';
|
|
48
65
|
const TRACKING_ACTIVE_TAB_KEY = 'midscene-tracking-active-tab';
|
|
@@ -0,0 +1,50 @@
|
|
|
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 ('undefined' != 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
|
+
default: ()=>show_marker
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
require("react");
|
|
31
|
+
const SvgShowMarker = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("svg", {
|
|
32
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
+
width: 16,
|
|
34
|
+
height: 16,
|
|
35
|
+
fill: "none",
|
|
36
|
+
viewBox: "0 0 16 16",
|
|
37
|
+
...props,
|
|
38
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
|
|
39
|
+
fill: "#333",
|
|
40
|
+
d: "M13 1.835a2.165 2.165 0 0 1 .665 4.225v3.88a2.166 2.166 0 1 1-2.725 2.725H5.06a2.165 2.165 0 1 1-2.725-2.726V6.06A2.165 2.165 0 1 1 5.06 3.336h5.88c.281-.87 1.097-1.5 2.06-1.5m-10 9.33a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67m10 0a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67m-7.94-6.5A2.17 2.17 0 0 1 3.665 6.06v3.88c.66.213 1.181.734 1.395 1.395h5.88a2.17 2.17 0 0 1 1.395-1.396V6.06a2.17 2.17 0 0 1-1.395-1.394zM3 3.165a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67m10 0a.835.835 0 1 0 0 1.67.835.835 0 0 0 0-1.67"
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
const show_marker = SvgShowMarker;
|
|
44
|
+
exports["default"] = __webpack_exports__["default"];
|
|
45
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
46
|
+
"default"
|
|
47
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
48
|
+
Object.defineProperty(exports, '__esModule', {
|
|
49
|
+
value: true
|
|
50
|
+
});
|
package/dist/lib/index.js
CHANGED
|
@@ -53,7 +53,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
53
53
|
checkServerStatus: ()=>playground_utils_js_namespaceObject.checkServerStatus,
|
|
54
54
|
blankResult: ()=>playground_utils_js_namespaceObject.blankResult,
|
|
55
55
|
useEnvConfig: ()=>store_js_namespaceObject.useEnvConfig,
|
|
56
|
-
Describer: ()=>describer_js_namespaceObject.Describer,
|
|
57
56
|
PromptInput: ()=>PromptInput_js_namespaceObject.PromptInput,
|
|
58
57
|
ContextPreview: ()=>ContextPreview_js_namespaceObject.ContextPreview,
|
|
59
58
|
requestPlaygroundServer: ()=>playground_utils_js_namespaceObject.requestPlaygroundServer,
|
|
@@ -83,14 +82,12 @@ const PromptInput_js_namespaceObject = require("./component/playground/PromptInp
|
|
|
83
82
|
const player_js_namespaceObject = require("./component/player.js");
|
|
84
83
|
const blackboard_js_namespaceObject = require("./component/blackboard.js");
|
|
85
84
|
const github_star_js_namespaceObject = require("./component/github-star.js");
|
|
86
|
-
const describer_js_namespaceObject = require("./component/describer.js");
|
|
87
85
|
const playground_utils_js_namespaceObject = require("./component/playground/playground-utils.js");
|
|
88
86
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
89
87
|
const shiny_text_js_namespaceObject = require("./component/shiny-text.js");
|
|
90
88
|
var shiny_text_js_default = /*#__PURE__*/ __webpack_require__.n(shiny_text_js_namespaceObject);
|
|
91
89
|
exports.Blackboard = __webpack_exports__.Blackboard;
|
|
92
90
|
exports.ContextPreview = __webpack_exports__.ContextPreview;
|
|
93
|
-
exports.Describer = __webpack_exports__.Describer;
|
|
94
91
|
exports.EnvConfig = __webpack_exports__.EnvConfig;
|
|
95
92
|
exports.GithubStar = __webpack_exports__.GithubStar;
|
|
96
93
|
exports.Logo = __webpack_exports__.Logo;
|
|
@@ -124,7 +121,6 @@ exports.useStaticPageAgent = __webpack_exports__.useStaticPageAgent;
|
|
|
124
121
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
125
122
|
"Blackboard",
|
|
126
123
|
"ContextPreview",
|
|
127
|
-
"Describer",
|
|
128
124
|
"EnvConfig",
|
|
129
125
|
"GithubStar",
|
|
130
126
|
"Logo",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as Z from 'zustand';
|
|
2
2
|
export declare const useBlackboardPreference: Z.UseBoundStore<Z.StoreApi<{
|
|
3
|
-
|
|
3
|
+
backgroundVisible: boolean;
|
|
4
4
|
elementsVisible: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
autoZoom: boolean;
|
|
6
|
+
setBackgroundVisible: (visible: boolean) => void;
|
|
7
|
+
setElementsVisible: (visible: boolean) => void;
|
|
8
|
+
setAutoZoom: (enabled: boolean) => void;
|
|
7
9
|
}>>;
|
|
8
10
|
/**
|
|
9
11
|
* Service Mode
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { PromptInput } from './component/playground/PromptInput';
|
|
|
15
15
|
export { Player } from './component/player';
|
|
16
16
|
export { Blackboard } from './component/blackboard';
|
|
17
17
|
export { GithubStar } from './component/github-star';
|
|
18
|
-
export { Describer } from './component/describer';
|
|
19
18
|
export { requestPlaygroundServer, cancelTask, overrideServerConfig, getTaskProgress, checkServerStatus, actionNameForType, staticAgentFromContext, formatErrorMessage, getPlaceholderForType, blankResult, } from './component/playground/playground-utils';
|
|
20
19
|
export { timeStr, filterBase64Value } from './utils';
|
|
21
20
|
export { default as ShinyText } from './component/shiny-text';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/visualizer",
|
|
3
|
-
"version": "0.26.7-beta-
|
|
3
|
+
"version": "0.26.7-beta-20250820150415.0",
|
|
4
4
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
5
5
|
"homepage": "https://midscenejs.com/",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"antd": "^5.21.6",
|
|
71
71
|
"buffer": "6.0.3",
|
|
72
72
|
"dayjs": "^1.11.11",
|
|
73
|
-
"@midscene/core": "0.26.7-beta-
|
|
74
|
-
"@midscene/
|
|
75
|
-
"@midscene/
|
|
73
|
+
"@midscene/core": "0.26.7-beta-20250820150415.0",
|
|
74
|
+
"@midscene/web": "0.26.7-beta-20250820150415.0",
|
|
75
|
+
"@midscene/shared": "0.26.7-beta-20250820150415.0"
|
|
76
76
|
},
|
|
77
77
|
"license": "MIT",
|
|
78
78
|
"scripts": {
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useRef, useState } from "react";
|
|
4
|
-
import { useStaticPageAgent } from "./playground/useStaticPageAgent.mjs";
|
|
5
|
-
import "./describer.css";
|
|
6
|
-
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
7
|
-
import { Blackboard } from "./blackboard.mjs";
|
|
8
|
-
import { PlaygroundResultView } from "./playground/PlaygroundResult.mjs";
|
|
9
|
-
const Describer = (props)=>{
|
|
10
|
-
var _result_verifyResult;
|
|
11
|
-
const { uiContext } = props;
|
|
12
|
-
const image = uiContext.screenshotBase64;
|
|
13
|
-
const canvasRef = useRef(null);
|
|
14
|
-
const [highlightPoints, setHighlightPoints] = useState([]);
|
|
15
|
-
const [highlightRect, setHighlightRect] = useState();
|
|
16
|
-
const [error, setError] = useState();
|
|
17
|
-
const [loading, setLoading] = useState(false);
|
|
18
|
-
const [result, setResult] = useState();
|
|
19
|
-
const agent = useStaticPageAgent(uiContext);
|
|
20
|
-
useEffect(()=>{
|
|
21
|
-
const canvas = canvasRef.current;
|
|
22
|
-
if (!canvas || !image) return;
|
|
23
|
-
const ctx = canvas.getContext('2d');
|
|
24
|
-
if (!ctx) return;
|
|
25
|
-
const img = new Image();
|
|
26
|
-
img.onload = ()=>{
|
|
27
|
-
canvas.width = img.width;
|
|
28
|
-
canvas.height = img.height;
|
|
29
|
-
ctx.drawImage(img, 0, 0);
|
|
30
|
-
};
|
|
31
|
-
img.src = image;
|
|
32
|
-
}, [
|
|
33
|
-
image
|
|
34
|
-
]);
|
|
35
|
-
const handleClick = async (position)=>{
|
|
36
|
-
if (!agent) return void console.error('agent is not initialized');
|
|
37
|
-
setLoading(true);
|
|
38
|
-
setError(void 0);
|
|
39
|
-
setResult(void 0);
|
|
40
|
-
setHighlightPoints([]);
|
|
41
|
-
setHighlightRect(void 0);
|
|
42
|
-
try {
|
|
43
|
-
var _result_verifyResult;
|
|
44
|
-
const userLocation = [
|
|
45
|
-
position[0],
|
|
46
|
-
position[1]
|
|
47
|
-
];
|
|
48
|
-
setHighlightPoints([
|
|
49
|
-
userLocation
|
|
50
|
-
]);
|
|
51
|
-
const result = await (null == agent ? void 0 : agent.describeElementAtPoint(userLocation));
|
|
52
|
-
console.log('describe result', result);
|
|
53
|
-
setResult(result);
|
|
54
|
-
if (null == (_result_verifyResult = result.verifyResult) ? void 0 : _result_verifyResult.rect) setHighlightRect(result.verifyResult.rect);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
setError(error.message);
|
|
57
|
-
} finally{
|
|
58
|
-
setLoading(false);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
let resultText = '';
|
|
62
|
-
if (error) resultText = error;
|
|
63
|
-
else if (!result || (null == (_result_verifyResult = result.verifyResult) ? void 0 : _result_verifyResult.pass)) {
|
|
64
|
-
if (result) resultText = result.deepThink ? `Deep think: ${result.prompt}` : result.prompt;
|
|
65
|
-
else if (loading) resultText = 'Loading...';
|
|
66
|
-
} else resultText = `Locate failed with prompt: ${result.prompt}`;
|
|
67
|
-
return /*#__PURE__*/ jsx("div", {
|
|
68
|
-
className: "image-describer",
|
|
69
|
-
children: /*#__PURE__*/ jsxs(PanelGroup, {
|
|
70
|
-
autoSaveId: "describer-layout",
|
|
71
|
-
direction: "horizontal",
|
|
72
|
-
children: [
|
|
73
|
-
/*#__PURE__*/ jsx(Panel, {
|
|
74
|
-
defaultSize: 32,
|
|
75
|
-
maxSize: 60,
|
|
76
|
-
minSize: 20,
|
|
77
|
-
style: {
|
|
78
|
-
paddingRight: '24px'
|
|
79
|
-
},
|
|
80
|
-
children: /*#__PURE__*/ jsxs("div", {
|
|
81
|
-
className: "form-part context-panel",
|
|
82
|
-
children: [
|
|
83
|
-
/*#__PURE__*/ jsx("h3", {
|
|
84
|
-
children: "Screenshot"
|
|
85
|
-
}),
|
|
86
|
-
/*#__PURE__*/ jsx("div", {
|
|
87
|
-
className: "form-sub-title",
|
|
88
|
-
children: "Click on the screenshot, Midscene will help you describe the element at the clicked point."
|
|
89
|
-
}),
|
|
90
|
-
/*#__PURE__*/ jsx(Blackboard, {
|
|
91
|
-
uiContext: {
|
|
92
|
-
...uiContext,
|
|
93
|
-
tree: {
|
|
94
|
-
node: null,
|
|
95
|
-
children: []
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
highlightPoints: highlightPoints,
|
|
99
|
-
highlightRect: highlightRect,
|
|
100
|
-
onCanvasClick: handleClick,
|
|
101
|
-
hideController: true
|
|
102
|
-
})
|
|
103
|
-
]
|
|
104
|
-
})
|
|
105
|
-
}),
|
|
106
|
-
/*#__PURE__*/ jsx(PanelResizeHandle, {
|
|
107
|
-
className: "panel-resize-handle"
|
|
108
|
-
}),
|
|
109
|
-
/*#__PURE__*/ jsx(Panel, {
|
|
110
|
-
children: /*#__PURE__*/ jsx(PlaygroundResultView, {
|
|
111
|
-
result: {
|
|
112
|
-
result: resultText,
|
|
113
|
-
error: error || null
|
|
114
|
-
},
|
|
115
|
-
loading: loading,
|
|
116
|
-
serverValid: true,
|
|
117
|
-
serviceMode: 'In-Browser',
|
|
118
|
-
replayScriptsInfo: null,
|
|
119
|
-
replayCounter: 0,
|
|
120
|
-
loadingProgressText: ''
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
]
|
|
124
|
-
})
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
const describer = Describer;
|
|
128
|
-
export { Describer, describer as default };
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
var __webpack_require__ = {};
|
|
4
|
-
(()=>{
|
|
5
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: definition[key]
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.r = (exports1)=>{
|
|
17
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
-
value: 'Module'
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
-
value: true
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
})();
|
|
25
|
-
var __webpack_exports__ = {};
|
|
26
|
-
__webpack_require__.r(__webpack_exports__);
|
|
27
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
-
Describer: ()=>Describer,
|
|
29
|
-
default: ()=>describer
|
|
30
|
-
});
|
|
31
|
-
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
32
|
-
const external_react_namespaceObject = require("react");
|
|
33
|
-
const useStaticPageAgent_js_namespaceObject = require("./playground/useStaticPageAgent.js");
|
|
34
|
-
require("./describer.css");
|
|
35
|
-
const external_react_resizable_panels_namespaceObject = require("react-resizable-panels");
|
|
36
|
-
const external_blackboard_js_namespaceObject = require("./blackboard.js");
|
|
37
|
-
const PlaygroundResult_js_namespaceObject = require("./playground/PlaygroundResult.js");
|
|
38
|
-
const Describer = (props)=>{
|
|
39
|
-
var _result_verifyResult;
|
|
40
|
-
const { uiContext } = props;
|
|
41
|
-
const image = uiContext.screenshotBase64;
|
|
42
|
-
const canvasRef = (0, external_react_namespaceObject.useRef)(null);
|
|
43
|
-
const [highlightPoints, setHighlightPoints] = (0, external_react_namespaceObject.useState)([]);
|
|
44
|
-
const [highlightRect, setHighlightRect] = (0, external_react_namespaceObject.useState)();
|
|
45
|
-
const [error, setError] = (0, external_react_namespaceObject.useState)();
|
|
46
|
-
const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
47
|
-
const [result, setResult] = (0, external_react_namespaceObject.useState)();
|
|
48
|
-
const agent = (0, useStaticPageAgent_js_namespaceObject.useStaticPageAgent)(uiContext);
|
|
49
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
50
|
-
const canvas = canvasRef.current;
|
|
51
|
-
if (!canvas || !image) return;
|
|
52
|
-
const ctx = canvas.getContext('2d');
|
|
53
|
-
if (!ctx) return;
|
|
54
|
-
const img = new Image();
|
|
55
|
-
img.onload = ()=>{
|
|
56
|
-
canvas.width = img.width;
|
|
57
|
-
canvas.height = img.height;
|
|
58
|
-
ctx.drawImage(img, 0, 0);
|
|
59
|
-
};
|
|
60
|
-
img.src = image;
|
|
61
|
-
}, [
|
|
62
|
-
image
|
|
63
|
-
]);
|
|
64
|
-
const handleClick = async (position)=>{
|
|
65
|
-
if (!agent) return void console.error('agent is not initialized');
|
|
66
|
-
setLoading(true);
|
|
67
|
-
setError(void 0);
|
|
68
|
-
setResult(void 0);
|
|
69
|
-
setHighlightPoints([]);
|
|
70
|
-
setHighlightRect(void 0);
|
|
71
|
-
try {
|
|
72
|
-
var _result_verifyResult;
|
|
73
|
-
const userLocation = [
|
|
74
|
-
position[0],
|
|
75
|
-
position[1]
|
|
76
|
-
];
|
|
77
|
-
setHighlightPoints([
|
|
78
|
-
userLocation
|
|
79
|
-
]);
|
|
80
|
-
const result = await (null == agent ? void 0 : agent.describeElementAtPoint(userLocation));
|
|
81
|
-
console.log('describe result', result);
|
|
82
|
-
setResult(result);
|
|
83
|
-
if (null == (_result_verifyResult = result.verifyResult) ? void 0 : _result_verifyResult.rect) setHighlightRect(result.verifyResult.rect);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
setError(error.message);
|
|
86
|
-
} finally{
|
|
87
|
-
setLoading(false);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
let resultText = '';
|
|
91
|
-
if (error) resultText = error;
|
|
92
|
-
else if (!result || (null == (_result_verifyResult = result.verifyResult) ? void 0 : _result_verifyResult.pass)) {
|
|
93
|
-
if (result) resultText = result.deepThink ? `Deep think: ${result.prompt}` : result.prompt;
|
|
94
|
-
else if (loading) resultText = 'Loading...';
|
|
95
|
-
} else resultText = `Locate failed with prompt: ${result.prompt}`;
|
|
96
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
97
|
-
className: "image-describer",
|
|
98
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_react_resizable_panels_namespaceObject.PanelGroup, {
|
|
99
|
-
autoSaveId: "describer-layout",
|
|
100
|
-
direction: "horizontal",
|
|
101
|
-
children: [
|
|
102
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
|
|
103
|
-
defaultSize: 32,
|
|
104
|
-
maxSize: 60,
|
|
105
|
-
minSize: 20,
|
|
106
|
-
style: {
|
|
107
|
-
paddingRight: '24px'
|
|
108
|
-
},
|
|
109
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
110
|
-
className: "form-part context-panel",
|
|
111
|
-
children: [
|
|
112
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h3", {
|
|
113
|
-
children: "Screenshot"
|
|
114
|
-
}),
|
|
115
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
116
|
-
className: "form-sub-title",
|
|
117
|
-
children: "Click on the screenshot, Midscene will help you describe the element at the clicked point."
|
|
118
|
-
}),
|
|
119
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_blackboard_js_namespaceObject.Blackboard, {
|
|
120
|
-
uiContext: {
|
|
121
|
-
...uiContext,
|
|
122
|
-
tree: {
|
|
123
|
-
node: null,
|
|
124
|
-
children: []
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
highlightPoints: highlightPoints,
|
|
128
|
-
highlightRect: highlightRect,
|
|
129
|
-
onCanvasClick: handleClick,
|
|
130
|
-
hideController: true
|
|
131
|
-
})
|
|
132
|
-
]
|
|
133
|
-
})
|
|
134
|
-
}),
|
|
135
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.PanelResizeHandle, {
|
|
136
|
-
className: "panel-resize-handle"
|
|
137
|
-
}),
|
|
138
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
|
|
139
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(PlaygroundResult_js_namespaceObject.PlaygroundResultView, {
|
|
140
|
-
result: {
|
|
141
|
-
result: resultText,
|
|
142
|
-
error: error || null
|
|
143
|
-
},
|
|
144
|
-
loading: loading,
|
|
145
|
-
serverValid: true,
|
|
146
|
-
serviceMode: 'In-Browser',
|
|
147
|
-
replayScriptsInfo: null,
|
|
148
|
-
replayCounter: 0,
|
|
149
|
-
loadingProgressText: ''
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
]
|
|
153
|
-
})
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
const describer = Describer;
|
|
157
|
-
exports.Describer = __webpack_exports__.Describer;
|
|
158
|
-
exports["default"] = __webpack_exports__["default"];
|
|
159
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
160
|
-
"Describer",
|
|
161
|
-
"default"
|
|
162
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
163
|
-
Object.defineProperty(exports, '__esModule', {
|
|
164
|
-
value: true
|
|
165
|
-
});
|