@midscene/visualizer 0.26.2-beta-20250812091127.0 → 0.26.3-beta-20250813021342.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.
Files changed (124) hide show
  1. package/dist/es/blank_polyfill.mjs +2 -0
  2. package/dist/es/component/blackboard.css +12 -5
  3. package/dist/es/component/blackboard.mjs +266 -0
  4. package/dist/es/component/color.mjs +35 -0
  5. package/dist/es/component/describer.css +9 -5
  6. package/dist/es/component/describer.mjs +128 -0
  7. package/dist/es/component/env-config.mjs +112 -0
  8. package/dist/es/component/github-star.css +1 -0
  9. package/dist/es/component/github-star.mjs +20 -0
  10. package/dist/es/component/logo.css +5 -3
  11. package/dist/es/component/logo.mjs +20 -0
  12. package/dist/es/component/misc.mjs +54 -0
  13. package/dist/es/component/pixi-loader.mjs +16 -0
  14. package/dist/es/component/player.css +88 -70
  15. package/dist/es/component/player.mjs +628 -0
  16. package/dist/es/component/playground/ConfigSelector.mjs +53 -0
  17. package/dist/es/component/playground/ContextPreview.mjs +39 -0
  18. package/dist/es/component/playground/HistorySelector.mjs +193 -0
  19. package/dist/es/component/playground/PlaygroundResult.mjs +60 -0
  20. package/dist/es/component/playground/PromptInput.mjs +225 -0
  21. package/dist/es/component/playground/ServiceModeControl.mjs +100 -0
  22. package/dist/es/component/playground/index.css +140 -98
  23. package/dist/es/component/playground/playground-constants.mjs +45 -0
  24. package/dist/es/component/playground/playground-utils.mjs +89 -0
  25. package/dist/es/component/playground/useServerValid.mjs +27 -0
  26. package/dist/es/component/playground/useStaticPageAgent.mjs +12 -0
  27. package/dist/es/component/replay-scripts.mjs +271 -0
  28. package/dist/es/component/shiny-text.css +33 -22
  29. package/dist/es/component/shiny-text.mjs +15 -0
  30. package/dist/es/component/store/history.mjs +55 -0
  31. package/dist/es/component/store/store.mjs +128 -0
  32. package/dist/es/icons/close.mjs +19 -0
  33. package/dist/es/icons/history.mjs +30 -0
  34. package/dist/es/icons/magnifying-glass.mjs +39 -0
  35. package/dist/es/icons/setting.mjs +20 -0
  36. package/dist/es/index.mjs +21 -0
  37. package/dist/es/init.mjs +10 -0
  38. package/dist/es/{utils.js → utils.mjs} +51 -75
  39. package/dist/lib/blank_polyfill.js +34 -38
  40. package/dist/lib/component/blackboard.css +12 -5
  41. package/dist/lib/component/blackboard.js +293 -306
  42. package/dist/lib/component/color.js +64 -74
  43. package/dist/lib/component/describer.css +9 -5
  44. package/dist/lib/component/describer.js +158 -198
  45. package/dist/lib/component/env-config.js +142 -147
  46. package/dist/lib/component/github-star.css +1 -0
  47. package/dist/lib/component/github-star.js +51 -62
  48. package/dist/lib/component/logo.css +5 -3
  49. package/dist/lib/component/logo.js +53 -56
  50. package/dist/lib/component/misc.js +85 -84
  51. package/dist/lib/component/pixi-loader.js +49 -80
  52. package/dist/lib/component/player.css +88 -70
  53. package/dist/lib/component/player.js +627 -738
  54. package/dist/lib/component/playground/ConfigSelector.js +91 -92
  55. package/dist/lib/component/playground/ContextPreview.js +80 -72
  56. package/dist/lib/component/playground/HistorySelector.js +234 -197
  57. package/dist/lib/component/playground/PlaygroundResult.js +100 -103
  58. package/dist/lib/component/playground/PromptInput.js +250 -237
  59. package/dist/lib/component/playground/ServiceModeControl.js +124 -124
  60. package/dist/lib/component/playground/index.css +140 -98
  61. package/dist/lib/component/playground/playground-constants.js +97 -73
  62. package/dist/lib/component/playground/playground-types.js +17 -31
  63. package/dist/lib/component/playground/playground-utils.js +140 -168
  64. package/dist/lib/component/playground/useServerValid.js +55 -86
  65. package/dist/lib/component/playground/useStaticPageAgent.js +45 -51
  66. package/dist/lib/component/replay-scripts.js +291 -373
  67. package/dist/lib/component/shiny-text.css +33 -22
  68. package/dist/lib/component/shiny-text.js +46 -57
  69. package/dist/lib/component/store/history.js +58 -64
  70. package/dist/lib/component/store/store.js +132 -128
  71. package/dist/lib/icons/close.js +53 -0
  72. package/dist/lib/icons/history.js +64 -0
  73. package/dist/lib/icons/magnifying-glass.js +73 -0
  74. package/dist/lib/icons/setting.js +54 -0
  75. package/dist/lib/index.js +158 -124
  76. package/dist/lib/init.js +39 -46
  77. package/dist/lib/utils.js +105 -109
  78. package/dist/types/blank_polyfill.d.ts +2 -2
  79. package/dist/types/component/playground/ConfigSelector.d.ts +1 -0
  80. package/dist/types/component/playground/ContextPreview.d.ts +1 -0
  81. package/dist/types/component/playground/HistorySelector.d.ts +1 -0
  82. package/dist/types/component/playground/PlaygroundResult.d.ts +1 -0
  83. package/dist/types/component/playground/PromptInput.d.ts +1 -0
  84. package/dist/types/component/playground/ServiceModeControl.d.ts +1 -0
  85. package/package.json +16 -18
  86. package/dist/es/assets/close.909351c0.svg +0 -4
  87. package/dist/es/assets/history.164a4eab.svg +0 -4
  88. package/dist/es/assets/magnifying-glass.9498e70e.svg +0 -12
  89. package/dist/es/assets/setting.80ab7285.svg +0 -11
  90. package/dist/es/blank_polyfill.js +0 -10
  91. package/dist/es/component/blackboard.js +0 -286
  92. package/dist/es/component/color.js +0 -49
  93. package/dist/es/component/describer.js +0 -173
  94. package/dist/es/component/env-config.js +0 -117
  95. package/dist/es/component/github-star.js +0 -31
  96. package/dist/es/component/logo.js +0 -25
  97. package/dist/es/component/misc.js +0 -63
  98. package/dist/es/component/pixi-loader.js +0 -51
  99. package/dist/es/component/player.js +0 -746
  100. package/dist/es/component/playground/ConfigSelector.js +0 -64
  101. package/dist/es/component/playground/ContextPreview.js +0 -42
  102. package/dist/es/component/playground/HistorySelector.js +0 -168
  103. package/dist/es/component/playground/PlaygroundResult.js +0 -73
  104. package/dist/es/component/playground/PromptInput.js +0 -212
  105. package/dist/es/component/playground/ServiceModeControl.js +0 -100
  106. package/dist/es/component/playground/playground-constants.js +0 -39
  107. package/dist/es/component/playground/playground-types.js +0 -6
  108. package/dist/es/component/playground/playground-utils.js +0 -141
  109. package/dist/es/component/playground/useServerValid.js +0 -58
  110. package/dist/es/component/playground/useStaticPageAgent.js +0 -20
  111. package/dist/es/component/replay-scripts.js +0 -361
  112. package/dist/es/component/shiny-text.js +0 -30
  113. package/dist/es/component/store/history.js +0 -34
  114. package/dist/es/component/store/store.js +0 -99
  115. package/dist/es/index.js +0 -79
  116. package/dist/es/init.js +0 -17
  117. package/dist/index.css +0 -595
  118. package/dist/index.js +0 -1
  119. package/dist/lib/assets/close.909351c0.svg +0 -4
  120. package/dist/lib/assets/history.164a4eab.svg +0 -4
  121. package/dist/lib/assets/magnifying-glass.9498e70e.svg +0 -12
  122. package/dist/lib/assets/setting.80ab7285.svg +0 -11
  123. package/dist/lib/component/common.css +0 -0
  124. /package/dist/es/component/{common.css → playground/playground-types.mjs} +0 -0
@@ -1,85 +1,75 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var color_exports = {};
30
- __export(color_exports, {
31
- colorForName: () => colorForName,
32
- globalThemeConfig: () => globalThemeConfig,
33
- highlightColorForType: () => highlightColorForType
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
+ colorForName: ()=>colorForName,
28
+ globalThemeConfig: ()=>globalThemeConfig,
29
+ highlightColorForType: ()=>highlightColorForType
34
30
  });
35
- module.exports = __toCommonJS(color_exports);
36
- var import_buffer = __toESM(require("buffer"));
37
- var import_browser = __toESM(require("process/browser"));
38
- var import_console_browserify = __toESM(require("console-browserify"));
39
- var buffer = {
40
- Buffer: import_buffer.default
41
- };
42
- const elementColor = ["#01204E"];
43
- const highlightColorForSearchArea = "#028391";
44
- const highlightColorForElement = "#fd5907";
31
+ const elementColor = [
32
+ '#01204E'
33
+ ];
34
+ const highlightColorForSearchArea = '#028391';
35
+ const highlightColorForElement = '#fd5907';
45
36
  function djb2Hash(str) {
46
- if (!str) {
47
- str = "unnamed";
48
- }
49
- let hash = 5381;
50
- for (let i = 0; i < str.length; i++) {
51
- hash = (hash << 5) + hash + str.charCodeAt(i);
52
- }
53
- return hash >>> 0;
37
+ if (!str) str = 'unnamed';
38
+ let hash = 5381;
39
+ for(let i = 0; i < str.length; i++)hash = (hash << 5) + hash + str.charCodeAt(i);
40
+ return hash >>> 0;
54
41
  }
55
42
  function colorForName(name) {
56
- const hashNumber = djb2Hash(name);
57
- return elementColor[hashNumber % elementColor.length];
43
+ const hashNumber = djb2Hash(name);
44
+ return elementColor[hashNumber % elementColor.length];
58
45
  }
59
46
  function highlightColorForType(type) {
60
- if (type === "searchArea") {
61
- return highlightColorForSearchArea;
62
- }
63
- return highlightColorForElement;
47
+ if ('searchArea' === type) return highlightColorForSearchArea;
48
+ return highlightColorForElement;
64
49
  }
65
50
  function globalThemeConfig() {
66
- return {
67
- token: {
68
- colorPrimary: "#2B83FF"
69
- },
70
- components: {
71
- Layout: {
72
- headerHeight: 60,
73
- headerPadding: "0 30px",
74
- headerBg: "#FFF",
75
- bodyBg: "#FFF"
76
- }
77
- }
78
- };
51
+ return {
52
+ token: {
53
+ colorPrimary: '#2B83FF'
54
+ },
55
+ components: {
56
+ Layout: {
57
+ headerHeight: 60,
58
+ headerPadding: '0 30px',
59
+ headerBg: '#FFF',
60
+ bodyBg: '#FFF'
61
+ }
62
+ }
63
+ };
79
64
  }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- colorForName,
83
- globalThemeConfig,
84
- highlightColorForType
65
+ exports.colorForName = __webpack_exports__.colorForName;
66
+ exports.globalThemeConfig = __webpack_exports__.globalThemeConfig;
67
+ exports.highlightColorForType = __webpack_exports__.highlightColorForType;
68
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
69
+ "colorForName",
70
+ "globalThemeConfig",
71
+ "highlightColorForType"
72
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
73
+ Object.defineProperty(exports, '__esModule', {
74
+ value: true
85
75
  });
@@ -1,21 +1,25 @@
1
1
  .image-describer {
2
2
  position: relative;
3
3
  }
4
+
4
5
  .image-describer .describe-text {
5
6
  box-sizing: border-box;
6
- position: absolute;
7
+ color: #fff;
7
8
  background: #000;
8
9
  width: 100%;
9
10
  height: 30px;
10
- left: 0;
11
- bottom: 0;
12
- color: #FFF;
13
- font-size: 12px;
14
11
  padding: 10px;
12
+ font-size: 12px;
13
+ position: absolute;
14
+ bottom: 0;
15
+ left: 0;
15
16
  }
17
+
16
18
  .image-describer .describe-text.success {
17
19
  background: #047704;
18
20
  }
21
+
19
22
  .image-describer .describe-text.error {
20
23
  background: #870707;
21
24
  }
25
+
@@ -1,205 +1,165 @@
1
+ 'use client';
1
2
  "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __defProps = Object.defineProperties;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
- var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __spreadValues = (a, b) => {
15
- for (var prop in b || (b = {}))
16
- if (__hasOwnProp.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- if (__getOwnPropSymbols)
19
- for (var prop of __getOwnPropSymbols(b)) {
20
- if (__propIsEnum.call(b, prop))
21
- __defNormalProp(a, prop, b[prop]);
22
- }
23
- return a;
24
- };
25
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
- var __export = (target, all) => {
27
- for (var name in all)
28
- __defProp(target, name, { get: all[name], enumerable: true });
29
- };
30
- var __copyProps = (to, from, except, desc) => {
31
- if (from && typeof from === "object" || typeof from === "function") {
32
- for (let key of __getOwnPropNames(from))
33
- if (!__hasOwnProp.call(to, key) && key !== except)
34
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
35
- }
36
- return to;
37
- };
38
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
39
- // If the importer is in node compatibility mode or this is not an ESM
40
- // file that has been converted to a CommonJS file using a Babel-
41
- // compatible transform (i.e. "__esModule" has not been set), then set
42
- // "default" to the CommonJS "module.exports" for node compatibility.
43
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
44
- mod
45
- ));
46
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
- var __async = (__this, __arguments, generator) => {
48
- return new Promise((resolve, reject) => {
49
- var fulfilled = (value) => {
50
- try {
51
- step(generator.next(value));
52
- } catch (e) {
53
- reject(e);
54
- }
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
+ });
55
10
  };
56
- var rejected = (value) => {
57
- try {
58
- step(generator.throw(value));
59
- } catch (e) {
60
- reject(e);
61
- }
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
+ });
62
23
  };
63
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
64
- step((generator = generator.apply(__this, __arguments)).next());
65
- });
66
- };
67
- var describer_exports = {};
68
- __export(describer_exports, {
69
- Describer: () => Describer,
70
- default: () => describer_default
24
+ })();
25
+ var __webpack_exports__ = {};
26
+ __webpack_require__.r(__webpack_exports__);
27
+ __webpack_require__.d(__webpack_exports__, {
28
+ Describer: ()=>Describer,
29
+ default: ()=>describer
71
30
  });
72
- module.exports = __toCommonJS(describer_exports);
73
- var import_buffer = __toESM(require("buffer"));
74
- var import_browser = __toESM(require("process/browser"));
75
- var import_console_browserify = __toESM(require("console-browserify"));
76
- var buffer = {
77
- Buffer: import_buffer.default
78
- };
79
- var import_jsx_runtime = require("react/jsx-runtime");
80
- var import_react = require("react");
81
- var import_useStaticPageAgent = require("./playground/useStaticPageAgent");
82
- var import_describer = require("./describer.css");
83
- var import_react_resizable_panels = require("react-resizable-panels");
84
- var import_blackboard = require("./blackboard");
85
- var import_PlaygroundResult = require("./playground/PlaygroundResult");
86
- const Describer = (props) => {
87
- var _a;
88
- const { uiContext } = props;
89
- const image = uiContext.screenshotBase64;
90
- const canvasRef = (0, import_react.useRef)(null);
91
- const [highlightPoints, setHighlightPoints] = (0, import_react.useState)(
92
- []
93
- );
94
- const [highlightRect, setHighlightRect] = (0, import_react.useState)();
95
- const [error, setError] = (0, import_react.useState)();
96
- const [loading, setLoading] = (0, import_react.useState)(false);
97
- const [result, setResult] = (0, import_react.useState)();
98
- const agent = (0, import_useStaticPageAgent.useStaticPageAgent)(uiContext);
99
- (0, import_react.useEffect)(() => {
100
- const canvas = canvasRef.current;
101
- if (!canvas || !image)
102
- return;
103
- const ctx = canvas.getContext("2d");
104
- if (!ctx)
105
- return;
106
- const img = new Image();
107
- img.onload = () => {
108
- canvas.width = img.width;
109
- canvas.height = img.height;
110
- ctx.drawImage(img, 0, 0);
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
+ }
111
89
  };
112
- img.src = image;
113
- }, [image]);
114
- const handleClick = (position) => __async(void 0, null, function* () {
115
- var _a2;
116
- if (!agent) {
117
- import_console_browserify.default.error("agent is not initialized");
118
- return;
119
- }
120
- setLoading(true);
121
- setError(void 0);
122
- setResult(void 0);
123
- setHighlightPoints([]);
124
- setHighlightRect(void 0);
125
- try {
126
- const userLocation = [position[0], position[1]];
127
- setHighlightPoints([userLocation]);
128
- const result2 = yield agent == null ? void 0 : agent.describeElementAtPoint(userLocation);
129
- import_console_browserify.default.log("describe result", result2);
130
- setResult(result2);
131
- if ((_a2 = result2.verifyResult) == null ? void 0 : _a2.rect) {
132
- setHighlightRect(result2.verifyResult.rect);
133
- }
134
- } catch (error2) {
135
- setError(error2.message);
136
- } finally {
137
- setLoading(false);
138
- }
139
- });
140
- let resultText = "";
141
- if (error) {
142
- resultText = error;
143
- } else if (result && !((_a = result.verifyResult) == null ? void 0 : _a.pass)) {
144
- resultText = `Locate failed with prompt: ${result.prompt}`;
145
- } else if (result) {
146
- if (result.deepThink) {
147
- resultText = `Deep think: ${result.prompt}`;
148
- } else {
149
- resultText = result.prompt;
150
- }
151
- } else if (loading) {
152
- resultText = "Loading...";
153
- }
154
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "image-describer", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_resizable_panels.PanelGroup, { autoSaveId: "describer-layout", direction: "horizontal", children: [
155
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
156
- import_react_resizable_panels.Panel,
157
- {
158
- defaultSize: 32,
159
- maxSize: 60,
160
- minSize: 20,
161
- style: { paddingRight: "24px" },
162
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "form-part context-panel", children: [
163
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Screenshot" }),
164
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "form-sub-title", children: "Click on the screenshot, Midscene will help you describe the element at the clicked point." }),
165
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
- import_blackboard.Blackboard,
167
- {
168
- uiContext: __spreadProps(__spreadValues({}, uiContext), {
169
- tree: {
170
- node: null,
171
- children: []
172
- }
173
- }),
174
- highlightPoints,
175
- highlightRect,
176
- onCanvasClick: handleClick,
177
- hideController: true
178
- }
179
- )
180
- ] })
181
- }
182
- ),
183
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_resizable_panels.PanelResizeHandle, { className: "panel-resize-handle" }),
184
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_resizable_panels.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
185
- import_PlaygroundResult.PlaygroundResultView,
186
- {
187
- result: {
188
- result: resultText,
189
- error: error || null
190
- },
191
- loading,
192
- serverValid: true,
193
- serviceMode: "In-Browser",
194
- replayScriptsInfo: null,
195
- replayCounter: 0,
196
- loadingProgressText: ""
197
- }
198
- ) })
199
- ] }) });
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
+ });
200
155
  };
201
- var describer_default = Describer;
202
- // Annotate the CommonJS export names for ESM import in node:
203
- 0 && (module.exports = {
204
- Describer
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
205
165
  });