@ohos-perf/core 0.22.2 → 0.22.3

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 (2) hide show
  1. package/dist/index.js +33 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8756,6 +8756,38 @@ function targetOf(tree, x, y) {
8756
8756
  };
8757
8757
  return containing.slice().sort((a, b) => Number(b.clickable) - Number(a.clickable) || area(a) - area(b))[0];
8758
8758
  }
8759
+ function rectOf2(node) {
8760
+ return node.boundsRect ?? parseBounds(node.bounds);
8761
+ }
8762
+ function gapTo(rect, x, y) {
8763
+ return Math.max(rect.left - x, 0, x - rect.right, rect.top - y, 0, y - rect.bottom);
8764
+ }
8765
+ function containsRect(outer, inner) {
8766
+ return outer.left <= inner.left && outer.top <= inner.top && outer.right >= inner.right && outer.bottom >= inner.bottom;
8767
+ }
8768
+ var NEAR_MISS_PX = 24;
8769
+ function nearMissOf(tree, x, y, landedOn) {
8770
+ let best;
8771
+ for (const node of tree) {
8772
+ if (irreversibleReason(node) === void 0) continue;
8773
+ const rect = rectOf2(node);
8774
+ if (rect === void 0) continue;
8775
+ const gap = gapTo(rect, x, y);
8776
+ if (gap > NEAR_MISS_PX) continue;
8777
+ if (landedOn !== void 0 && landedOn !== node && landedOn.clickable) {
8778
+ const landing = rectOf2(landedOn);
8779
+ if (landing === void 0 || !containsRect(landing, rect)) continue;
8780
+ }
8781
+ if (best === void 0 || gap < best.gap) best = { node, gap };
8782
+ }
8783
+ return best;
8784
+ }
8785
+ function refusalFor(tree, x, y, landedOn) {
8786
+ const direct = landedOn === void 0 ? void 0 : irreversibleReason(landedOn);
8787
+ if (direct !== void 0) return direct;
8788
+ const near = nearMissOf(tree, x, y, landedOn);
8789
+ return near === void 0 ? void 0 : irreversibleReason(near.node);
8790
+ }
8759
8791
  function unmetExpectation(expect, tree, app) {
8760
8792
  const outcomes = evaluateExpectation(expect, tree, app);
8761
8793
  const failed = outcomes.filter((outcome) => !outcome.ok);
@@ -8825,7 +8857,7 @@ async function runAgent(device, model, options) {
8825
8857
  const gesture = decision.action;
8826
8858
  const point = gesture.action === "click" || gesture.action === "inputText" ? { x: gesture.x, y: gesture.y } : void 0;
8827
8859
  const target = point === void 0 ? void 0 : targetOf(tree, point.x, point.y);
8828
- const refused = target === void 0 ? void 0 : irreversibleReason(target);
8860
+ const refused = point === void 0 ? void 0 : refusalFor(tree, point.x, point.y, target);
8829
8861
  if (refused !== void 0 && options.allowIrreversible !== true) {
8830
8862
  status = "refused";
8831
8863
  steps.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohos-perf/core",
3
- "version": "0.22.2",
3
+ "version": "0.22.3",
4
4
  "description": "HarmonyOS performance analysis: capability probing, nine collectors, trace ingest, typed queries, twenty-one analyzers with provenance and fidelity, reports and a scenario runner",
5
5
  "keywords": [
6
6
  "harmonyos",