@midscene/visualizer 0.15.2 → 0.15.3-beta-20250423152742.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.
@@ -76,7 +76,7 @@ const Blackboard = (props) => {
76
76
  const highlightIds = highlightElements.map((e) => e.id);
77
77
  const highlightRect = props.highlightRect;
78
78
  const context = props.uiContext;
79
- const { size, screenshotBase64, screenshotBase64WithElementMarker } = context;
79
+ const { size, screenshotBase64 } = context;
80
80
  const screenWidth = size.width;
81
81
  const screenHeight = size.height;
82
82
  const domRef = useRef(null);
@@ -87,7 +87,6 @@ const Blackboard = (props) => {
87
87
  const [hoverElement, setHoverElement] = useState(null);
88
88
  const pixiBgRef = useRef();
89
89
  const { markerVisible, setMarkerVisible, elementsVisible, setTextsVisible } = useBlackboardPreference();
90
- const ifMarkerAvailable = !!screenshotBase64WithElementMarker;
91
90
  useEffect(() => {
92
91
  Promise.resolve(
93
92
  (() => __async(void 0, null, function* () {
@@ -138,24 +137,6 @@ const Blackboard = (props) => {
138
137
  backgroundSprite.width = screenWidth;
139
138
  backgroundSprite.height = screenHeight;
140
139
  app.stage.addChildAt(backgroundSprite, 0);
141
- if (ifMarkerAvailable) {
142
- const markerImg = new Image();
143
- markerImg.onload = () => {
144
- const markerTexture = PIXI.Texture.from(markerImg);
145
- const markerSprite = new PIXI.Sprite(markerTexture);
146
- markerSprite.x = 0;
147
- markerSprite.y = 0;
148
- markerSprite.width = screenWidth;
149
- markerSprite.height = screenHeight;
150
- app.stage.addChildAt(markerSprite, 1);
151
- pixiBgRef.current = markerSprite;
152
- markerSprite.visible = markerVisible;
153
- };
154
- markerImg.onerror = (e) => {
155
- console.error("load marker failed", e);
156
- };
157
- markerImg.src = screenshotBase64WithElementMarker;
158
- }
159
140
  };
160
141
  img.onerror = (e) => {
161
142
  console.error("load screenshot failed", e);
@@ -241,18 +222,7 @@ const Blackboard = (props) => {
241
222
  {
242
223
  className: "blackboard-filter",
243
224
  style: { display: props.hideController ? "none" : "block" },
244
- children: /* @__PURE__ */ jsxs("div", { className: "overlay-control", children: [
245
- /* @__PURE__ */ jsx(
246
- Checkbox,
247
- {
248
- checked: markerVisible,
249
- onChange: onSetMarkerVisible,
250
- disabled: !ifMarkerAvailable,
251
- children: "Marker"
252
- }
253
- ),
254
- /* @__PURE__ */ jsx(Checkbox, { checked: elementsVisible, onChange: onSetElementsVisible, children: "Elements" })
255
- ] })
225
+ children: /* @__PURE__ */ jsx("div", { className: "overlay-control", children: /* @__PURE__ */ jsx(Checkbox, { checked: elementsVisible, onChange: onSetElementsVisible, children: "Elements" }) })
256
226
  }
257
227
  ),
258
228
  /* @__PURE__ */ jsx(
@@ -452,7 +452,7 @@ function Player(props) {
452
452
  let cancelFn;
453
453
  Promise.resolve(
454
454
  (() => __async(this, null, function* () {
455
- var _a2;
455
+ var _a2, _b;
456
456
  if (!app) {
457
457
  throw new Error("app is not initialized");
458
458
  }
@@ -496,12 +496,12 @@ function Player(props) {
496
496
  }
497
497
  currentImg.current = item.img;
498
498
  yield repaintImage();
499
- const elements = item.insightDump.context.content;
499
+ const elements = ((_a2 = item.context) == null ? void 0 : _a2.content) || [];
500
500
  const highlightElements = item.insightDump.matchedElement;
501
501
  yield insightElementsAnimation(
502
502
  elements,
503
503
  highlightElements,
504
- (_a2 = item.insightDump.taskInfo) == null ? void 0 : _a2.searchArea,
504
+ (_b = item.insightDump.taskInfo) == null ? void 0 : _b.searchArea,
505
505
  item.duration,
506
506
  frame
507
507
  );
@@ -189,7 +189,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
189
189
  let initSubTitle = "";
190
190
  let errorStateFlag = false;
191
191
  tasksIncluded.forEach((task2, index) => {
192
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
192
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
193
193
  if (errorStateFlag)
194
194
  return;
195
195
  if (task2.type === "Planning") {
@@ -205,7 +205,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
205
205
  });
206
206
  initSubTitle = paramStr(task2);
207
207
  }
208
- } else if (task2.type === "Insight") {
208
+ } else if (task2.type === "Insight" && task2.subType === "Locate") {
209
209
  const insightTask = task2;
210
210
  const resultElement = (_c = insightTask.output) == null ? void 0 : _c.element;
211
211
  const title = typeStr(task2);
@@ -216,16 +216,14 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
216
216
  pointerTop: resultElement.center[1]
217
217
  });
218
218
  }
219
- if ((_d = insightTask.log) == null ? void 0 : _d.dump) {
219
+ const context = insightTask.pageContext;
220
+ if (((_d = insightTask.log) == null ? void 0 : _d.dump) && (context == null ? void 0 : context.screenshotBase64)) {
220
221
  const insightDump = insightTask.log.dump;
221
- if (!((_e = insightDump == null ? void 0 : insightDump.context) == null ? void 0 : _e.screenshotBase64)) {
222
- throw new Error("insight dump is required");
223
- }
224
- const insightContentLength = insightDump.context.content.length;
225
- if (insightDump.context.screenshotBase64WithElementMarker) {
222
+ const insightContentLength = context.content.length;
223
+ if (context.screenshotBase64) {
226
224
  scripts.push({
227
225
  type: "img",
228
- img: insightDump.context.screenshotBase64,
226
+ img: context.screenshotBase64,
229
227
  duration: stillAfterInsightDuration,
230
228
  title,
231
229
  subTitle
@@ -244,7 +242,8 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
244
242
  }
245
243
  scripts.push({
246
244
  type: "insight",
247
- img: insightDump.context.screenshotBase64WithElementMarker || insightDump.context.screenshotBase64,
245
+ img: context.screenshotBase64,
246
+ context,
248
247
  insightDump,
249
248
  camera: cameraState,
250
249
  duration: insightContentLength > 20 ? locateDuration : locateDuration * 0.5,
@@ -267,7 +266,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
267
266
  currentCameraState = insightCameraState != null ? insightCameraState : fullPageCameraState;
268
267
  scripts.push({
269
268
  type: "img",
270
- img: (_g = (_f = task2.recorder) == null ? void 0 : _f[0]) == null ? void 0 : _g.screenshot,
269
+ img: (_f = (_e = task2.recorder) == null ? void 0 : _e[0]) == null ? void 0 : _f.screenshot,
271
270
  duration: actionDuration,
272
271
  camera: task2.subType === "Sleep" ? fullPageCameraState : insightCameraState,
273
272
  title,
@@ -283,7 +282,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
283
282
  insightOnTop = false;
284
283
  }
285
284
  const imgStillDuration = index < taskCount - 1 ? stillDuration : 0;
286
- if ((_i = (_h = task2.recorder) == null ? void 0 : _h[1]) == null ? void 0 : _i.screenshot) {
285
+ if ((_h = (_g = task2.recorder) == null ? void 0 : _g[1]) == null ? void 0 : _h.screenshot) {
287
286
  scripts.push({
288
287
  type: "spinning-pointer",
289
288
  duration: actionSpinningPointerDuration,
@@ -293,7 +292,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight) => {
293
292
  scripts.push(pointerScript(mousePointer, title, subTitle));
294
293
  scripts.push({
295
294
  type: "img",
296
- img: (_k = (_j = task2.recorder) == null ? void 0 : _j[1]) == null ? void 0 : _k.screenshot,
295
+ img: (_j = (_i = task2.recorder) == null ? void 0 : _i[1]) == null ? void 0 : _j.screenshot,
297
296
  duration: imgStillDuration,
298
297
  title,
299
298
  subTitle