storyboard-bridge 0.9.21 → 0.9.22

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/cdp_flow.py +25 -10
  2. package/package.json +1 -1
package/cdp_flow.py CHANGED
@@ -529,27 +529,42 @@ def main():
529
529
  step_vars[var] = ""
530
530
  elif kind == "drag":
531
531
  xpath, direction, steps_count, duration = val[0], val[1], int(val[2]), float(val[3])
532
- # Simple drag implementation: find element and simulate drag to the right
533
- box = page.eval(f"""
532
+ # Drag implementation: find element, emit mousedown, mousemove sequence, mouseup
533
+ start_x, start_y = page.eval(f"""
534
534
  (function() {{
535
535
  const el = document.evaluate({json.dumps(xpath)}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
536
536
  if (!el) return null;
537
537
  const rect = el.getBoundingClientRect();
538
- return {{ x: rect.left + rect.width/2, y: rect.top + rect.height/2, width: rect.width }};
538
+ return [rect.left + rect.width/2, rect.top + rect.height/2];
539
539
  }})()
540
540
  """)
541
- if box:
542
- start_x, start_y = int(box["x"]), int(box["y"])
541
+ if start_x is not None:
542
+ start_x, start_y = int(start_x), int(start_y)
543
543
  end_x = start_x + (200 if direction == "right" else -200)
544
544
  step_duration = duration / steps_count
545
+ page.eval(f"""
546
+ (function() {{
547
+ const el = document.evaluate({json.dumps(xpath)}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
548
+ const ev = new PointerEvent('pointerdown', {{ clientX: {start_x}, clientY: {start_y}, bubbles: true, cancelable: true }});
549
+ el.dispatchEvent(ev);
550
+ }})()
551
+ """)
545
552
  for step_i in range(steps_count):
546
553
  x = start_x + (end_x - start_x) * (step_i / steps_count)
547
- page.cdp.call("Input.dispatchMouseEvent", {
548
- "type": "mouseMoved",
549
- "x": int(x),
550
- "y": start_y,
551
- })
554
+ page.eval(f"""
555
+ (function() {{
556
+ const ev = new PointerEvent('pointermove', {{ clientX: {int(x)}, clientY: {start_y}, bubbles: true, cancelable: true }});
557
+ document.elementFromPoint({int(x)}, {start_y})?.dispatchEvent(ev);
558
+ }})()
559
+ """)
552
560
  time.sleep(step_duration)
561
+ page.eval(f"""
562
+ (function() {{
563
+ const el = document.elementFromPoint({end_x}, {start_y});
564
+ const ev = new PointerEvent('pointerup', {{ clientX: {end_x}, clientY: {start_y}, bubbles: true, cancelable: true }});
565
+ el?.dispatchEvent(ev);
566
+ }})()
567
+ """)
553
568
  print(f" dragged {direction}")
554
569
  time.sleep(delay)
555
570
  print("flow complete")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storyboard-bridge",
3
- "version": "0.9.21",
3
+ "version": "0.9.22",
4
4
  "description": "Desktop bridge that powers a hosted Storyboard AI webapp with your own local Claude Code / Gemini CLI login (no API key).",
5
5
  "type": "module",
6
6
  "bin": {