@midscene/visualizer 0.26.2 → 0.26.3-beta-20250813075706.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 -19
  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,396 +1,314 @@
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 replay_scripts_exports = {};
48
- __export(replay_scripts_exports, {
49
- allScriptsFromDump: () => allScriptsFromDump,
50
- cameraStateForRect: () => cameraStateForRect,
51
- generateAnimationScripts: () => generateAnimationScripts,
52
- mergeTwoCameraState: () => mergeTwoCameraState
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
+ cameraStateForRect: ()=>cameraStateForRect,
29
+ mergeTwoCameraState: ()=>mergeTwoCameraState,
30
+ generateAnimationScripts: ()=>generateAnimationScripts,
31
+ allScriptsFromDump: ()=>allScriptsFromDump
53
32
  });
54
- module.exports = __toCommonJS(replay_scripts_exports);
55
- var import_buffer = __toESM(require("buffer"));
56
- var import_browser = __toESM(require("process/browser"));
57
- var import_console_browserify = __toESM(require("console-browserify"));
58
- var buffer = {
59
- Buffer: import_buffer.default
60
- };
61
- var import_player = require("./player.css");
62
- var import_utils = require("../utils");
63
- var import_ui_utils = require("@midscene/web/ui-utils");
64
- var import_extractor = require("@midscene/shared/extractor");
33
+ require("./player.css");
34
+ const external_utils_js_namespaceObject = require("../utils.js");
35
+ const ui_utils_namespaceObject = require("@midscene/web/ui-utils");
36
+ const extractor_namespaceObject = require("@midscene/shared/extractor");
65
37
  const stillDuration = 900;
66
38
  const actionSpinningPointerDuration = 300;
67
39
  const stillAfterInsightDuration = 300;
68
40
  const locateDuration = 800;
69
- const actionDuration = 1e3;
41
+ const actionDuration = 1000;
70
42
  const clearInsightDuration = 200;
71
- const cameraStateForRect = (rect, imageWidth, imageHeight) => {
72
- const canvasRatio = imageWidth / imageHeight;
73
- const rectRatio = rect.width / rect.height;
74
- let rectWidthOnPage;
75
- if (rectRatio >= canvasRatio) {
76
- rectWidthOnPage = rect.width;
77
- } else {
78
- rectWidthOnPage = rect.height / imageHeight * imageWidth;
79
- }
80
- const cameraPaddingRatio = rectWidthOnPage > 400 ? 0.1 : rectWidthOnPage > 50 ? 0.2 : 0.3;
81
- const cameraWidth = Math.min(
82
- imageWidth,
83
- rectWidthOnPage + imageWidth * cameraPaddingRatio * 2
84
- );
85
- const cameraHeight = cameraWidth * (imageHeight / imageWidth);
86
- let left = Math.min(
87
- rect.left - imageWidth * cameraPaddingRatio,
88
- imageWidth - cameraWidth
89
- );
90
- left = Math.max(left, 0);
91
- let top = Math.min(
92
- rect.top - imageHeight * cameraPaddingRatio,
93
- imageHeight - cameraHeight
94
- );
95
- top = Math.max(top, 0);
96
- return {
97
- left: Math.round(left),
98
- top: Math.round(top),
99
- width: Math.round(cameraWidth)
100
- };
101
- };
102
- const mergeTwoCameraState = (cameraState1, cameraState2) => {
103
- const newLeft = Math.min(cameraState1.left, cameraState2.left);
104
- const newTop = Math.min(cameraState1.top, cameraState2.top);
105
- const newRight = Math.max(
106
- cameraState1.left + cameraState1.width,
107
- cameraState2.left + cameraState2.width
108
- );
109
- const newWidth = newRight - newLeft;
110
- return {
111
- left: newLeft,
112
- top: newTop,
113
- width: newWidth
114
- };
43
+ const cameraStateForRect = (rect, imageWidth, imageHeight)=>{
44
+ const canvasRatio = imageWidth / imageHeight;
45
+ const rectRatio = rect.width / rect.height;
46
+ let rectWidthOnPage;
47
+ rectWidthOnPage = rectRatio >= canvasRatio ? rect.width : rect.height / imageHeight * imageWidth;
48
+ const cameraPaddingRatio = rectWidthOnPage > 400 ? 0.1 : rectWidthOnPage > 50 ? 0.2 : 0.3;
49
+ const cameraWidth = Math.min(imageWidth, rectWidthOnPage + imageWidth * cameraPaddingRatio * 2);
50
+ const cameraHeight = imageHeight / imageWidth * cameraWidth;
51
+ let left = Math.min(rect.left - imageWidth * cameraPaddingRatio, imageWidth - cameraWidth);
52
+ left = Math.max(left, 0);
53
+ let top = Math.min(rect.top - imageHeight * cameraPaddingRatio, imageHeight - cameraHeight);
54
+ top = Math.max(top, 0);
55
+ return {
56
+ left: Math.round(left),
57
+ top: Math.round(top),
58
+ width: Math.round(cameraWidth)
59
+ };
115
60
  };
116
- const allScriptsFromDump = (dump) => {
117
- let width = void 0;
118
- let height = void 0;
119
- let sdkVersion = void 0;
120
- let modelName = void 0;
121
- let modelDescription = void 0;
122
- dump.executions.forEach((execution) => {
123
- if (execution.sdkVersion) {
124
- sdkVersion = execution.sdkVersion;
125
- }
126
- if (execution.model_name) {
127
- modelName = execution.model_name;
128
- }
129
- if (execution.model_description) {
130
- modelDescription = execution.model_description;
131
- }
132
- execution.tasks.forEach((task) => {
133
- var _a, _b;
134
- const insightTask = task;
135
- if ((_b = (_a = insightTask.pageContext) == null ? void 0 : _a.size) == null ? void 0 : _b.width) {
136
- width = insightTask.pageContext.size.width;
137
- height = insightTask.pageContext.size.height;
138
- }
139
- });
140
- });
141
- if (!width || !height) {
142
- import_console_browserify.default.warn("width or height is missing in dump file");
61
+ const mergeTwoCameraState = (cameraState1, cameraState2)=>{
62
+ const newLeft = Math.min(cameraState1.left, cameraState2.left);
63
+ const newTop = Math.min(cameraState1.top, cameraState2.top);
64
+ const newRight = Math.max(cameraState1.left + cameraState1.width, cameraState2.left + cameraState2.width);
65
+ const newWidth = newRight - newLeft;
143
66
  return {
144
- scripts: [],
145
- sdkVersion,
146
- modelName,
147
- modelDescription
67
+ left: newLeft,
68
+ top: newTop,
69
+ width: newWidth
148
70
  };
149
- }
150
- const allScripts = [];
151
- dump.executions.forEach((execution) => {
152
- const scripts = generateAnimationScripts(execution, -1, width, height);
153
- if (scripts) {
154
- allScripts.push(...scripts);
155
- }
156
- });
157
- const allScriptsWithoutIntermediateDoneFrame = allScripts.filter(
158
- (script, index) => {
159
- if (index !== allScripts.length - 1 && script.title === "Done") {
160
- return false;
161
- }
162
- return true;
163
- }
164
- );
165
- return {
166
- scripts: allScriptsWithoutIntermediateDoneFrame,
167
- width,
168
- height,
169
- sdkVersion,
170
- modelName,
171
- modelDescription
172
- };
173
71
  };
174
- const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
175
- if (!execution || !execution.tasks.length)
176
- return null;
177
- if (imageWidth === 0 || imageHeight === 0) {
178
- return null;
179
- }
180
- let tasksIncluded = [];
181
- if (task === -1) {
182
- tasksIncluded = execution.tasks;
183
- } else {
184
- const startIndex = execution.tasks.findIndex((t) => t === task);
185
- if (startIndex === -1) {
186
- import_console_browserify.default.error("task not found, cannot generate animation scripts");
187
- return null;
188
- }
189
- if (startIndex === execution.tasks.length - 1) {
190
- return null;
191
- }
192
- for (let i = startIndex; i < execution.tasks.length; i++) {
193
- if (i > startIndex && execution.tasks[i].type === "Planning") {
194
- break;
195
- }
196
- tasksIncluded.push(execution.tasks[i]);
72
+ const allScriptsFromDump = (dump)=>{
73
+ let width;
74
+ let height;
75
+ let sdkVersion;
76
+ let modelName;
77
+ let modelDescription;
78
+ dump.executions.forEach((execution)=>{
79
+ if (execution.sdkVersion) sdkVersion = execution.sdkVersion;
80
+ if (execution.model_name) modelName = execution.model_name;
81
+ if (execution.model_description) modelDescription = execution.model_description;
82
+ execution.tasks.forEach((task)=>{
83
+ var _insightTask_pageContext_size, _insightTask_pageContext;
84
+ const insightTask = task;
85
+ if (null == (_insightTask_pageContext = insightTask.pageContext) ? void 0 : null == (_insightTask_pageContext_size = _insightTask_pageContext.size) ? void 0 : _insightTask_pageContext_size.width) {
86
+ width = insightTask.pageContext.size.width;
87
+ height = insightTask.pageContext.size.height;
88
+ }
89
+ });
90
+ });
91
+ if (!width || !height) {
92
+ console.warn('width or height is missing in dump file');
93
+ return {
94
+ scripts: [],
95
+ sdkVersion,
96
+ modelName,
97
+ modelDescription
98
+ };
197
99
  }
198
- }
199
- if (tasksIncluded.length === 0) {
200
- return null;
201
- }
202
- const fullPageCameraState = cameraStateForRect(
203
- {
204
- left: 0,
205
- top: 0,
206
- width: imageWidth,
207
- height: imageHeight
208
- },
209
- imageWidth,
210
- imageHeight
211
- );
212
- const pointerScript = (img, title, subTitle) => {
100
+ const allScripts = [];
101
+ dump.executions.forEach((execution)=>{
102
+ const scripts = generateAnimationScripts(execution, -1, width, height);
103
+ if (scripts) allScripts.push(...scripts);
104
+ });
105
+ const allScriptsWithoutIntermediateDoneFrame = allScripts.filter((script, index)=>{
106
+ if (index !== allScripts.length - 1 && 'Done' === script.title) return false;
107
+ return true;
108
+ });
213
109
  return {
214
- type: "pointer",
215
- img,
216
- duration: 0,
217
- title,
218
- subTitle
110
+ scripts: allScriptsWithoutIntermediateDoneFrame,
111
+ width,
112
+ height,
113
+ sdkVersion,
114
+ modelName,
115
+ modelDescription
219
116
  };
220
- };
221
- const scripts = [];
222
- let insightCameraState = void 0;
223
- let currentCameraState = fullPageCameraState;
224
- let insightOnTop = false;
225
- const taskCount = tasksIncluded.length;
226
- let initSubTitle = "";
227
- let errorStateFlag = false;
228
- tasksIncluded.forEach((task2, index) => {
229
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
230
- if (errorStateFlag)
231
- return;
232
- if (index === 0) {
233
- initSubTitle = (0, import_ui_utils.paramStr)(task2);
117
+ };
118
+ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
119
+ if (!execution || !execution.tasks.length) return null;
120
+ if (0 === imageWidth || 0 === imageHeight) return null;
121
+ let tasksIncluded = [];
122
+ if (-1 === task) tasksIncluded = execution.tasks;
123
+ else {
124
+ const startIndex = execution.tasks.findIndex((t)=>t === task);
125
+ if (-1 === startIndex) {
126
+ console.error("task not found, cannot generate animation scripts");
127
+ return null;
128
+ }
129
+ if (startIndex === execution.tasks.length - 1) return null;
130
+ for(let i = startIndex; i < execution.tasks.length; i++){
131
+ if (i > startIndex && 'Planning' === execution.tasks[i].type) break;
132
+ tasksIncluded.push(execution.tasks[i]);
133
+ }
234
134
  }
235
- if (task2.type === "Planning") {
236
- const planningTask = task2;
237
- if (planningTask.recorder && planningTask.recorder.length > 0) {
238
- scripts.push({
239
- type: "img",
240
- img: (_b = (_a = planningTask.recorder) == null ? void 0 : _a[0]) == null ? void 0 : _b.screenshot,
241
- camera: index === 0 ? fullPageCameraState : void 0,
242
- duration: stillDuration,
243
- title: (0, import_ui_utils.typeStr)(task2),
244
- subTitle: (0, import_ui_utils.paramStr)(task2)
245
- });
246
- }
247
- } else if (task2.type === "Insight" && task2.subType === "Locate") {
248
- const insightTask = task2;
249
- const resultElement = (_c = insightTask.output) == null ? void 0 : _c.element;
250
- const title = (0, import_ui_utils.typeStr)(task2);
251
- const subTitle = (0, import_ui_utils.paramStr)(task2);
252
- if (resultElement == null ? void 0 : resultElement.rect) {
253
- insightCameraState = __spreadProps(__spreadValues({}, cameraStateForRect(resultElement.rect, imageWidth, imageHeight)), {
254
- pointerLeft: resultElement.center[0],
255
- pointerTop: resultElement.center[1]
256
- });
257
- }
258
- const context = insightTask.pageContext;
259
- if (context == null ? void 0 : context.screenshotBase64) {
260
- const insightDump = (_d = insightTask.log) == null ? void 0 : _d.dump;
261
- const insightContentLength = context.tree ? (0, import_extractor.treeToList)(context.tree).length : 0;
262
- if (context.screenshotBase64) {
263
- scripts.push({
264
- type: "img",
265
- img: context.screenshotBase64,
266
- duration: stillAfterInsightDuration,
135
+ if (0 === tasksIncluded.length) return null;
136
+ const fullPageCameraState = cameraStateForRect({
137
+ left: 0,
138
+ top: 0,
139
+ width: imageWidth,
140
+ height: imageHeight
141
+ }, imageWidth, imageHeight);
142
+ const pointerScript = (img, title, subTitle)=>({
143
+ type: 'pointer',
144
+ img,
145
+ duration: 0,
267
146
  title,
268
147
  subTitle
269
- });
270
- }
271
- let cameraState = void 0;
272
- if (currentCameraState === fullPageCameraState) {
273
- cameraState = void 0;
274
- } else if (!insightCameraState) {
275
- cameraState = void 0;
148
+ });
149
+ const scripts = [];
150
+ let insightCameraState;
151
+ let currentCameraState = fullPageCameraState;
152
+ let insightOnTop = false;
153
+ const taskCount = tasksIncluded.length;
154
+ let initSubTitle = '';
155
+ let errorStateFlag = false;
156
+ tasksIncluded.forEach((task, index)=>{
157
+ if (errorStateFlag) return;
158
+ if (0 === index) initSubTitle = (0, ui_utils_namespaceObject.paramStr)(task);
159
+ if ('Planning' === task.type) {
160
+ const planningTask = task;
161
+ if (planningTask.recorder && planningTask.recorder.length > 0) {
162
+ var _planningTask_recorder_, _planningTask_recorder;
163
+ scripts.push({
164
+ type: 'img',
165
+ img: null == (_planningTask_recorder = planningTask.recorder) ? void 0 : null == (_planningTask_recorder_ = _planningTask_recorder[0]) ? void 0 : _planningTask_recorder_.screenshot,
166
+ camera: 0 === index ? fullPageCameraState : void 0,
167
+ duration: stillDuration,
168
+ title: (0, ui_utils_namespaceObject.typeStr)(task),
169
+ subTitle: (0, ui_utils_namespaceObject.paramStr)(task)
170
+ });
171
+ }
172
+ } else if ('Insight' === task.type && 'Locate' === task.subType) {
173
+ var _insightTask_output;
174
+ const insightTask = task;
175
+ const resultElement = null == (_insightTask_output = insightTask.output) ? void 0 : _insightTask_output.element;
176
+ const title = (0, ui_utils_namespaceObject.typeStr)(task);
177
+ const subTitle = (0, ui_utils_namespaceObject.paramStr)(task);
178
+ if (null == resultElement ? void 0 : resultElement.rect) insightCameraState = {
179
+ ...cameraStateForRect(resultElement.rect, imageWidth, imageHeight),
180
+ pointerLeft: resultElement.center[0],
181
+ pointerTop: resultElement.center[1]
182
+ };
183
+ const context = insightTask.pageContext;
184
+ if (null == context ? void 0 : context.screenshotBase64) {
185
+ var _insightTask_log, _insightTask_output1, _insightDump_taskInfo;
186
+ const insightDump = null == (_insightTask_log = insightTask.log) ? void 0 : _insightTask_log.dump;
187
+ const insightContentLength = context.tree ? (0, extractor_namespaceObject.treeToList)(context.tree).length : 0;
188
+ if (context.screenshotBase64) scripts.push({
189
+ type: 'img',
190
+ img: context.screenshotBase64,
191
+ duration: stillAfterInsightDuration,
192
+ title,
193
+ subTitle
194
+ });
195
+ let cameraState;
196
+ cameraState = currentCameraState === fullPageCameraState ? void 0 : insightCameraState ? mergeTwoCameraState(currentCameraState, insightCameraState) : void 0;
197
+ scripts.push({
198
+ type: 'insight',
199
+ img: context.screenshotBase64,
200
+ context: context,
201
+ camera: cameraState,
202
+ highlightElement: (null == (_insightTask_output1 = insightTask.output) ? void 0 : _insightTask_output1.element) || void 0,
203
+ searchArea: null == insightDump ? void 0 : null == (_insightDump_taskInfo = insightDump.taskInfo) ? void 0 : _insightDump_taskInfo.searchArea,
204
+ duration: insightContentLength > 20 ? locateDuration : 0.5 * locateDuration,
205
+ insightCameraDuration: locateDuration,
206
+ title,
207
+ subTitle
208
+ });
209
+ scripts.push({
210
+ type: 'sleep',
211
+ duration: stillAfterInsightDuration,
212
+ title,
213
+ subTitle
214
+ });
215
+ insightOnTop = true;
216
+ }
217
+ } else if ('Action' === task.type && 'FalsyConditionStatement' !== task.subType) {
218
+ var _task_recorder_, _task_recorder, _task_recorder_1, _task_recorder1;
219
+ const title = (0, ui_utils_namespaceObject.typeStr)(task);
220
+ const subTitle = (0, ui_utils_namespaceObject.paramStr)(task);
221
+ scripts.push(pointerScript(external_utils_js_namespaceObject.mousePointer, title, subTitle));
222
+ currentCameraState = null != insightCameraState ? insightCameraState : fullPageCameraState;
223
+ scripts.push({
224
+ type: 'img',
225
+ img: null == (_task_recorder = task.recorder) ? void 0 : null == (_task_recorder_ = _task_recorder[0]) ? void 0 : _task_recorder_.screenshot,
226
+ duration: actionDuration,
227
+ camera: 'Sleep' === task.subType ? fullPageCameraState : insightCameraState,
228
+ title,
229
+ subTitle
230
+ });
231
+ if (insightOnTop) {
232
+ scripts.push({
233
+ type: 'clear-insight',
234
+ duration: clearInsightDuration,
235
+ title,
236
+ subTitle
237
+ });
238
+ insightOnTop = false;
239
+ }
240
+ const imgStillDuration = index < taskCount - 1 ? stillDuration : 0;
241
+ if (null == (_task_recorder1 = task.recorder) ? void 0 : null == (_task_recorder_1 = _task_recorder1[1]) ? void 0 : _task_recorder_1.screenshot) {
242
+ var _task_recorder_2, _task_recorder2;
243
+ scripts.push({
244
+ type: 'spinning-pointer',
245
+ duration: actionSpinningPointerDuration,
246
+ title,
247
+ subTitle
248
+ });
249
+ scripts.push(pointerScript(external_utils_js_namespaceObject.mousePointer, title, subTitle));
250
+ scripts.push({
251
+ type: 'img',
252
+ img: null == (_task_recorder2 = task.recorder) ? void 0 : null == (_task_recorder_2 = _task_recorder2[1]) ? void 0 : _task_recorder_2.screenshot,
253
+ duration: imgStillDuration,
254
+ title,
255
+ subTitle
256
+ });
257
+ } else scripts.push({
258
+ type: 'sleep',
259
+ duration: imgStillDuration,
260
+ title,
261
+ subTitle
262
+ });
276
263
  } else {
277
- cameraState = mergeTwoCameraState(
278
- currentCameraState,
279
- insightCameraState
280
- );
264
+ var _task_recorder_3, _task_recorder3;
265
+ const title = (0, ui_utils_namespaceObject.typeStr)(task);
266
+ const subTitle = (0, ui_utils_namespaceObject.paramStr)(task);
267
+ const screenshot = null == (_task_recorder3 = task.recorder) ? void 0 : null == (_task_recorder_3 = _task_recorder3[task.recorder.length - 1]) ? void 0 : _task_recorder_3.screenshot;
268
+ if (screenshot) scripts.push({
269
+ type: 'img',
270
+ img: screenshot,
271
+ duration: stillDuration,
272
+ camera: fullPageCameraState,
273
+ title,
274
+ subTitle
275
+ });
281
276
  }
282
- scripts.push({
283
- type: "insight",
284
- img: context.screenshotBase64,
285
- context,
286
- camera: cameraState,
287
- highlightElement: ((_e = insightTask.output) == null ? void 0 : _e.element) || void 0,
288
- searchArea: (_f = insightDump == null ? void 0 : insightDump.taskInfo) == null ? void 0 : _f.searchArea,
289
- duration: insightContentLength > 20 ? locateDuration : locateDuration * 0.5,
290
- insightCameraDuration: locateDuration,
291
- title,
292
- subTitle
293
- });
294
- scripts.push({
295
- type: "sleep",
296
- duration: stillAfterInsightDuration,
297
- title,
298
- subTitle
299
- });
300
- insightOnTop = true;
301
- }
302
- } else if (task2.type === "Action" && task2.subType !== "FalsyConditionStatement") {
303
- const title = (0, import_ui_utils.typeStr)(task2);
304
- const subTitle = (0, import_ui_utils.paramStr)(task2);
305
- scripts.push(pointerScript(import_utils.mousePointer, title, subTitle));
306
- currentCameraState = insightCameraState != null ? insightCameraState : fullPageCameraState;
307
- scripts.push({
308
- type: "img",
309
- img: (_h = (_g = task2.recorder) == null ? void 0 : _g[0]) == null ? void 0 : _h.screenshot,
310
- duration: actionDuration,
311
- camera: task2.subType === "Sleep" ? fullPageCameraState : insightCameraState,
312
- title,
313
- subTitle
314
- });
315
- if (insightOnTop) {
316
- scripts.push({
317
- type: "clear-insight",
318
- duration: clearInsightDuration,
319
- title,
320
- subTitle
321
- });
322
- insightOnTop = false;
323
- }
324
- const imgStillDuration = index < taskCount - 1 ? stillDuration : 0;
325
- if ((_j = (_i = task2.recorder) == null ? void 0 : _i[1]) == null ? void 0 : _j.screenshot) {
326
- scripts.push({
327
- type: "spinning-pointer",
328
- duration: actionSpinningPointerDuration,
329
- title,
330
- subTitle
331
- });
332
- scripts.push(pointerScript(import_utils.mousePointer, title, subTitle));
333
- scripts.push({
334
- type: "img",
335
- img: (_l = (_k = task2.recorder) == null ? void 0 : _k[1]) == null ? void 0 : _l.screenshot,
336
- duration: imgStillDuration,
337
- title,
338
- subTitle
339
- });
340
- } else {
341
- scripts.push({
342
- type: "sleep",
343
- duration: imgStillDuration,
344
- title,
345
- subTitle
346
- });
347
- }
348
- } else {
349
- const title = (0, import_ui_utils.typeStr)(task2);
350
- const subTitle = (0, import_ui_utils.paramStr)(task2);
351
- const screenshot = (_n = (_m = task2.recorder) == null ? void 0 : _m[task2.recorder.length - 1]) == null ? void 0 : _n.screenshot;
352
- if (screenshot) {
353
- scripts.push({
354
- type: "img",
355
- img: screenshot,
356
- duration: stillDuration,
357
- camera: fullPageCameraState,
358
- title,
359
- subTitle
360
- });
361
- }
362
- }
363
- if (task2.status !== "finished") {
364
- errorStateFlag = true;
365
- const errorTitle = (0, import_ui_utils.typeStr)(task2);
366
- const errorMsg = task2.errorMessage || "unknown error";
367
- const errorSubTitle = errorMsg.indexOf("NOT_IMPLEMENTED_AS_DESIGNED") > 0 ? "Further actions cannot be performed in the current environment" : errorMsg;
368
- scripts.push({
369
- type: "img",
370
- img: task2.recorder && task2.recorder.length > 0 ? task2.recorder[task2.recorder.length - 1].screenshot : "",
371
- camera: fullPageCameraState,
277
+ if ('finished' !== task.status) {
278
+ errorStateFlag = true;
279
+ const errorTitle = (0, ui_utils_namespaceObject.typeStr)(task);
280
+ const errorMsg = task.errorMessage || 'unknown error';
281
+ const errorSubTitle = errorMsg.indexOf('NOT_IMPLEMENTED_AS_DESIGNED') > 0 ? 'Further actions cannot be performed in the current environment' : errorMsg;
282
+ scripts.push({
283
+ type: 'img',
284
+ img: task.recorder && task.recorder.length > 0 ? task.recorder[task.recorder.length - 1].screenshot : '',
285
+ camera: fullPageCameraState,
286
+ duration: stillDuration,
287
+ title: errorTitle,
288
+ subTitle: errorSubTitle
289
+ });
290
+ return;
291
+ }
292
+ });
293
+ if (!errorStateFlag) scripts.push({
294
+ title: 'Done',
295
+ subTitle: initSubTitle,
296
+ type: 'img',
372
297
  duration: stillDuration,
373
- title: errorTitle,
374
- subTitle: errorSubTitle
375
- });
376
- return;
377
- }
378
- });
379
- if (!errorStateFlag) {
380
- scripts.push({
381
- title: "Done",
382
- subTitle: initSubTitle,
383
- type: "img",
384
- duration: stillDuration,
385
- camera: fullPageCameraState
298
+ camera: fullPageCameraState
386
299
  });
387
- }
388
- return scripts;
300
+ return scripts;
389
301
  };
390
- // Annotate the CommonJS export names for ESM import in node:
391
- 0 && (module.exports = {
392
- allScriptsFromDump,
393
- cameraStateForRect,
394
- generateAnimationScripts,
395
- mergeTwoCameraState
302
+ exports.allScriptsFromDump = __webpack_exports__.allScriptsFromDump;
303
+ exports.cameraStateForRect = __webpack_exports__.cameraStateForRect;
304
+ exports.generateAnimationScripts = __webpack_exports__.generateAnimationScripts;
305
+ exports.mergeTwoCameraState = __webpack_exports__.mergeTwoCameraState;
306
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
307
+ "allScriptsFromDump",
308
+ "cameraStateForRect",
309
+ "generateAnimationScripts",
310
+ "mergeTwoCameraState"
311
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
312
+ Object.defineProperty(exports, '__esModule', {
313
+ value: true
396
314
  });