@midscene/visualizer 1.0.3-beta-20251223070556.0 → 1.0.4-beta-20251223105123.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.
@@ -731,7 +731,7 @@ function Player(props) {
731
731
  onClick: statusOnClick,
732
732
  children: statusIconElement
733
733
  }),
734
- (null == props ? void 0 : props.reportFileContent) ? /*#__PURE__*/ jsx(Tooltip, {
734
+ (null == props ? void 0 : props.reportFileContent) && (null == props ? void 0 : props.canDownloadReport) !== false ? /*#__PURE__*/ jsx(Tooltip, {
735
735
  title: "Download Report",
736
736
  children: /*#__PURE__*/ jsx("div", {
737
737
  className: "status-icon",
@@ -6,7 +6,7 @@ import { emptyResultTip, serverLaunchTip } from "../misc/index.mjs";
6
6
  import { Player } from "../player/index.mjs";
7
7
  import shiny_text from "../shiny-text/index.mjs";
8
8
  import "./index.css";
9
- const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, replayScriptsInfo, replayCounter, loadingProgressText, verticalMode = false, notReadyMessage, fitMode, autoZoom, actionType })=>{
9
+ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, replayScriptsInfo, replayCounter, loadingProgressText, verticalMode = false, notReadyMessage, fitMode, autoZoom, actionType, canDownloadReport })=>{
10
10
  let resultWrapperClassName = 'result-wrapper';
11
11
  if (verticalMode) resultWrapperClassName += ' vertical-mode-result';
12
12
  if (replayScriptsInfo && verticalMode) resultWrapperClassName += ' result-wrapper-compact';
@@ -31,10 +31,66 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
31
31
  })
32
32
  ]
33
33
  });
34
- else if (null == result ? void 0 : result.error) resultDataToShow = /*#__PURE__*/ jsx("pre", {
35
- children: null == result ? void 0 : result.error
36
- });
37
- else if (shouldPrioritizeResult && (null == result ? void 0 : result.result) !== void 0 && replayScriptsInfo) {
34
+ else if (null == result ? void 0 : result.error) {
35
+ const errorNode = /*#__PURE__*/ jsx("pre", {
36
+ style: {
37
+ color: '#ff4d4f',
38
+ whiteSpace: 'pre-wrap'
39
+ },
40
+ children: null == result ? void 0 : result.error
41
+ });
42
+ resultDataToShow = result.reportHTML || replayScriptsInfo ? /*#__PURE__*/ jsxs("div", {
43
+ style: {
44
+ display: 'flex',
45
+ flexDirection: 'column',
46
+ gap: '16px',
47
+ height: '100%'
48
+ },
49
+ children: [
50
+ /*#__PURE__*/ jsxs("div", {
51
+ style: {
52
+ flex: '0 0 auto',
53
+ maxHeight: '40%',
54
+ overflow: 'auto'
55
+ },
56
+ children: [
57
+ /*#__PURE__*/ jsx("div", {
58
+ style: {
59
+ fontWeight: 'bold',
60
+ marginBottom: '8px'
61
+ },
62
+ children: "Error:"
63
+ }),
64
+ errorNode
65
+ ]
66
+ }),
67
+ /*#__PURE__*/ jsxs("div", {
68
+ style: {
69
+ flex: '1 1 auto',
70
+ minHeight: 0
71
+ },
72
+ children: [
73
+ /*#__PURE__*/ jsx("div", {
74
+ style: {
75
+ fontWeight: 'bold',
76
+ marginBottom: '8px'
77
+ },
78
+ children: "Report:"
79
+ }),
80
+ /*#__PURE__*/ jsx(Player, {
81
+ replayScripts: null == replayScriptsInfo ? void 0 : replayScriptsInfo.scripts,
82
+ imageWidth: null == replayScriptsInfo ? void 0 : replayScriptsInfo.width,
83
+ imageHeight: null == replayScriptsInfo ? void 0 : replayScriptsInfo.height,
84
+ reportFileContent: result.reportHTML || null,
85
+ fitMode: fitMode,
86
+ autoZoom: autoZoom,
87
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
88
+ }, replayCounter)
89
+ ]
90
+ })
91
+ ]
92
+ }) : errorNode;
93
+ } else if (shouldPrioritizeResult && (null == result ? void 0 : result.result) !== void 0 && replayScriptsInfo) {
38
94
  const resultOutput = 'string' == typeof (null == result ? void 0 : result.result) ? /*#__PURE__*/ jsx("pre", {
39
95
  children: null == result ? void 0 : result.result
40
96
  }) : /*#__PURE__*/ jsx("pre", {
@@ -83,7 +139,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
83
139
  imageHeight: replayScriptsInfo.height,
84
140
  reportFileContent: reportContent,
85
141
  fitMode: fitMode,
86
- autoZoom: autoZoom
142
+ autoZoom: autoZoom,
143
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
87
144
  }, replayCounter)
88
145
  ]
89
146
  })
@@ -97,7 +154,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
97
154
  imageHeight: replayScriptsInfo.height,
98
155
  reportFileContent: reportContent,
99
156
  fitMode: fitMode,
100
- autoZoom: autoZoom
157
+ autoZoom: autoZoom,
158
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
101
159
  }, replayCounter);
102
160
  } else if (shouldPrioritizeResult && (null == result ? void 0 : result.result) !== void 0 && (null == result ? void 0 : result.reportHTML)) {
103
161
  const resultOutput = 'string' == typeof (null == result ? void 0 : result.result) ? /*#__PURE__*/ jsx("pre", {
@@ -144,7 +202,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
144
202
  /*#__PURE__*/ jsx(Player, {
145
203
  reportFileContent: result.reportHTML,
146
204
  fitMode: fitMode,
147
- autoZoom: autoZoom
205
+ autoZoom: autoZoom,
206
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
148
207
  }, replayCounter)
149
208
  ]
150
209
  })
@@ -158,7 +217,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
158
217
  else if (null == result ? void 0 : result.reportHTML) resultDataToShow = /*#__PURE__*/ jsx(Player, {
159
218
  reportFileContent: result.reportHTML,
160
219
  fitMode: fitMode,
161
- autoZoom: autoZoom
220
+ autoZoom: autoZoom,
221
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
162
222
  }, replayCounter);
163
223
  else if ((null == result ? void 0 : result.result) !== void 0) resultDataToShow = 'string' == typeof (null == result ? void 0 : result.result) ? /*#__PURE__*/ jsx("pre", {
164
224
  children: null == result ? void 0 : result.result
@@ -71,6 +71,16 @@ function _object_spread_props(target, source) {
71
71
  });
72
72
  return target;
73
73
  }
74
+ function formatError(error) {
75
+ if (!error) return '';
76
+ if ('string' == typeof error) return error;
77
+ if (error.message) return String(error.message);
78
+ try {
79
+ return JSON.stringify(error);
80
+ } catch (e) {
81
+ return String(error);
82
+ }
83
+ }
74
84
  function buildProgressContent(task) {
75
85
  const action = typeStr(task);
76
86
  const description = paramStr(task);
@@ -142,7 +152,7 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
142
152
  content: buildProgressContent(task),
143
153
  timestamp: new Date((null == (_task_timing = task.timing) ? void 0 : _task_timing.start) || Date.now()),
144
154
  result: task.error ? {
145
- error: String(task.error),
155
+ error: formatError(task.error),
146
156
  result: null
147
157
  } : void 0
148
158
  };
@@ -168,11 +178,11 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
168
178
  const resultObj = result.result;
169
179
  if (resultObj.dump) result.dump = resultObj.dump;
170
180
  if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
171
- if (resultObj.error) result.error = resultObj.error;
181
+ if (resultObj.error) result.error = formatError(resultObj.error);
172
182
  if (void 0 !== resultObj.result) result.result = resultObj.result;
173
183
  }
174
184
  } catch (e) {
175
- result.error = (null == e ? void 0 : e.message) || String(e);
185
+ result.error = formatError(e);
176
186
  console.error('Playground execution error:', e);
177
187
  if ('object' == typeof e && null !== e) {
178
188
  if (e.dump) result.dump = e.dump;
@@ -770,7 +770,7 @@ function Player(props) {
770
770
  onClick: statusOnClick,
771
771
  children: statusIconElement
772
772
  }),
773
- (null == props ? void 0 : props.reportFileContent) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
773
+ (null == props ? void 0 : props.reportFileContent) && (null == props ? void 0 : props.canDownloadReport) !== false ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
774
774
  title: "Download Report",
775
775
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
776
776
  className: "status-icon",
@@ -44,7 +44,7 @@ const external_player_index_js_namespaceObject = require("../player/index.js");
44
44
  const external_shiny_text_index_js_namespaceObject = require("../shiny-text/index.js");
45
45
  var external_shiny_text_index_js_default = /*#__PURE__*/ __webpack_require__.n(external_shiny_text_index_js_namespaceObject);
46
46
  require("./index.css");
47
- const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, replayScriptsInfo, replayCounter, loadingProgressText, verticalMode = false, notReadyMessage, fitMode, autoZoom, actionType })=>{
47
+ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, replayScriptsInfo, replayCounter, loadingProgressText, verticalMode = false, notReadyMessage, fitMode, autoZoom, actionType, canDownloadReport })=>{
48
48
  let resultWrapperClassName = 'result-wrapper';
49
49
  if (verticalMode) resultWrapperClassName += ' vertical-mode-result';
50
50
  if (replayScriptsInfo && verticalMode) resultWrapperClassName += ' result-wrapper-compact';
@@ -69,10 +69,66 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
69
69
  })
70
70
  ]
71
71
  });
72
- else if (null == result ? void 0 : result.error) resultDataToShow = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
73
- children: null == result ? void 0 : result.error
74
- });
75
- else if (shouldPrioritizeResult && (null == result ? void 0 : result.result) !== void 0 && replayScriptsInfo) {
72
+ else if (null == result ? void 0 : result.error) {
73
+ const errorNode = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
74
+ style: {
75
+ color: '#ff4d4f',
76
+ whiteSpace: 'pre-wrap'
77
+ },
78
+ children: null == result ? void 0 : result.error
79
+ });
80
+ resultDataToShow = result.reportHTML || replayScriptsInfo ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
81
+ style: {
82
+ display: 'flex',
83
+ flexDirection: 'column',
84
+ gap: '16px',
85
+ height: '100%'
86
+ },
87
+ children: [
88
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
89
+ style: {
90
+ flex: '0 0 auto',
91
+ maxHeight: '40%',
92
+ overflow: 'auto'
93
+ },
94
+ children: [
95
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
96
+ style: {
97
+ fontWeight: 'bold',
98
+ marginBottom: '8px'
99
+ },
100
+ children: "Error:"
101
+ }),
102
+ errorNode
103
+ ]
104
+ }),
105
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
106
+ style: {
107
+ flex: '1 1 auto',
108
+ minHeight: 0
109
+ },
110
+ children: [
111
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
112
+ style: {
113
+ fontWeight: 'bold',
114
+ marginBottom: '8px'
115
+ },
116
+ children: "Report:"
117
+ }),
118
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_player_index_js_namespaceObject.Player, {
119
+ replayScripts: null == replayScriptsInfo ? void 0 : replayScriptsInfo.scripts,
120
+ imageWidth: null == replayScriptsInfo ? void 0 : replayScriptsInfo.width,
121
+ imageHeight: null == replayScriptsInfo ? void 0 : replayScriptsInfo.height,
122
+ reportFileContent: result.reportHTML || null,
123
+ fitMode: fitMode,
124
+ autoZoom: autoZoom,
125
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
126
+ }, replayCounter)
127
+ ]
128
+ })
129
+ ]
130
+ }) : errorNode;
131
+ } else if (shouldPrioritizeResult && (null == result ? void 0 : result.result) !== void 0 && replayScriptsInfo) {
76
132
  const resultOutput = 'string' == typeof (null == result ? void 0 : result.result) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
77
133
  children: null == result ? void 0 : result.result
78
134
  }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
@@ -121,7 +177,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
121
177
  imageHeight: replayScriptsInfo.height,
122
178
  reportFileContent: reportContent,
123
179
  fitMode: fitMode,
124
- autoZoom: autoZoom
180
+ autoZoom: autoZoom,
181
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
125
182
  }, replayCounter)
126
183
  ]
127
184
  })
@@ -135,7 +192,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
135
192
  imageHeight: replayScriptsInfo.height,
136
193
  reportFileContent: reportContent,
137
194
  fitMode: fitMode,
138
- autoZoom: autoZoom
195
+ autoZoom: autoZoom,
196
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
139
197
  }, replayCounter);
140
198
  } else if (shouldPrioritizeResult && (null == result ? void 0 : result.result) !== void 0 && (null == result ? void 0 : result.reportHTML)) {
141
199
  const resultOutput = 'string' == typeof (null == result ? void 0 : result.result) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
@@ -182,7 +240,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
182
240
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_player_index_js_namespaceObject.Player, {
183
241
  reportFileContent: result.reportHTML,
184
242
  fitMode: fitMode,
185
- autoZoom: autoZoom
243
+ autoZoom: autoZoom,
244
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
186
245
  }, replayCounter)
187
246
  ]
188
247
  })
@@ -196,7 +255,8 @@ const PlaygroundResultView = ({ result, loading, serverValid, serviceMode, repla
196
255
  else if (null == result ? void 0 : result.reportHTML) resultDataToShow = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_player_index_js_namespaceObject.Player, {
197
256
  reportFileContent: result.reportHTML,
198
257
  fitMode: fitMode,
199
- autoZoom: autoZoom
258
+ autoZoom: autoZoom,
259
+ canDownloadReport: null != canDownloadReport ? canDownloadReport : 'In-Browser' !== serviceMode
200
260
  }, replayCounter);
201
261
  else if ((null == result ? void 0 : result.result) !== void 0) resultDataToShow = 'string' == typeof (null == result ? void 0 : result.result) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
202
262
  children: null == result ? void 0 : result.result
@@ -99,6 +99,16 @@ function _object_spread_props(target, source) {
99
99
  });
100
100
  return target;
101
101
  }
102
+ function formatError(error) {
103
+ if (!error) return '';
104
+ if ('string' == typeof error) return error;
105
+ if (error.message) return String(error.message);
106
+ try {
107
+ return JSON.stringify(error);
108
+ } catch (e) {
109
+ return String(error);
110
+ }
111
+ }
102
112
  function buildProgressContent(task) {
103
113
  const action = (0, agent_namespaceObject.typeStr)(task);
104
114
  const description = (0, agent_namespaceObject.paramStr)(task);
@@ -170,7 +180,7 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
170
180
  content: buildProgressContent(task),
171
181
  timestamp: new Date((null == (_task_timing = task.timing) ? void 0 : _task_timing.start) || Date.now()),
172
182
  result: task.error ? {
173
- error: String(task.error),
183
+ error: formatError(task.error),
174
184
  result: null
175
185
  } : void 0
176
186
  };
@@ -196,11 +206,11 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
196
206
  const resultObj = result.result;
197
207
  if (resultObj.dump) result.dump = resultObj.dump;
198
208
  if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
199
- if (resultObj.error) result.error = resultObj.error;
209
+ if (resultObj.error) result.error = formatError(resultObj.error);
200
210
  if (void 0 !== resultObj.result) result.result = resultObj.result;
201
211
  }
202
212
  } catch (e) {
203
- result.error = (null == e ? void 0 : e.message) || String(e);
213
+ result.error = formatError(e);
204
214
  console.error('Playground execution error:', e);
205
215
  if ('object' == typeof e && null !== e) {
206
216
  if (e.dump) result.dump = e.dump;
@@ -9,4 +9,5 @@ export declare function Player(props?: {
9
9
  key?: string | number;
10
10
  fitMode?: 'width' | 'height';
11
11
  autoZoom?: boolean;
12
+ canDownloadReport?: boolean;
12
13
  }): import("react").JSX.Element;
@@ -16,6 +16,7 @@ interface PlaygroundResultProps {
16
16
  fitMode?: 'width' | 'height';
17
17
  autoZoom?: boolean;
18
18
  actionType?: string;
19
+ canDownloadReport?: boolean;
19
20
  }
20
21
  export declare const PlaygroundResultView: React.FC<PlaygroundResultProps>;
21
22
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/visualizer",
3
- "version": "1.0.3-beta-20251223070556.0",
3
+ "version": "1.0.4-beta-20251223105123.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",
@@ -60,10 +60,10 @@
60
60
  "antd": "^5.21.6",
61
61
  "buffer": "6.0.3",
62
62
  "dayjs": "^1.11.11",
63
- "@midscene/playground": "1.0.3-beta-20251223070556.0",
64
- "@midscene/shared": "1.0.3-beta-20251223070556.0",
65
- "@midscene/web": "1.0.3-beta-20251223070556.0",
66
- "@midscene/core": "1.0.3-beta-20251223070556.0"
63
+ "@midscene/core": "1.0.4-beta-20251223105123.0",
64
+ "@midscene/playground": "1.0.4-beta-20251223105123.0",
65
+ "@midscene/shared": "1.0.4-beta-20251223105123.0",
66
+ "@midscene/web": "1.0.4-beta-20251223105123.0"
67
67
  },
68
68
  "license": "MIT",
69
69
  "scripts": {