storyboard-bridge 0.9.39 → 0.9.40

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 +37 -31
  2. package/package.json +1 -1
package/cdp_flow.py CHANGED
@@ -534,40 +534,46 @@ def main():
534
534
  step_vars[var] = ""
535
535
  elif kind == "drag":
536
536
  xpath, direction, steps_count, duration = val[0], val[1], int(val[2]), float(val[3])
537
- delta = 1000 if direction == "right" else -1000
538
- step_ms = int(duration * 1000 / steps_count)
539
- # Simulate drag using JavaScript—fires events synchronously
540
- page.eval(f"""
537
+ # Find handle position
538
+ box = page.eval(f"""
541
539
  (function() {{
542
- const handle = document.evaluate({json.dumps(xpath)}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
543
- if (!handle) return;
544
- const rect = handle.getBoundingClientRect();
545
- const startX = rect.left + rect.width/2;
546
- const startY = rect.top + rect.height/2;
547
- const endX = startX + {delta};
548
-
549
- // Fire mousedown
550
- handle.dispatchEvent(new MouseEvent('mousedown', {{
551
- clientX: startX, clientY: startY, bubbles: true, cancelable: true
552
- }}));
553
-
554
- // Fire mousemove sequence synchronously
555
- const steps = {steps_count};
556
- for (let i = 0; i <= steps; i++) {{
557
- const x = startX + (endX - startX) * (i / steps);
558
- const el = document.elementFromPoint(x, startY) || handle;
559
- el.dispatchEvent(new MouseEvent('mousemove', {{
560
- clientX: x, clientY: startY, bubbles: true, cancelable: true
561
- }}));
562
- }}
563
-
564
- // Fire mouseup
565
- handle.dispatchEvent(new MouseEvent('mouseup', {{
566
- clientX: endX, clientY: startY, bubbles: true, cancelable: true
567
- }}));
540
+ const el = document.evaluate({json.dumps(xpath)}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
541
+ if (!el) return null;
542
+ const rect = el.getBoundingClientRect();
543
+ return {{ x: rect.left + rect.width/2, y: rect.top + rect.height/2, width: rect.width }};
568
544
  }})()
569
545
  """)
570
- print(f" dragged {direction}")
546
+ if box:
547
+ start_x, start_y = int(box["x"]), int(box["y"])
548
+ end_x = start_x + (1000 if direction == "right" else -1000)
549
+ step_duration = duration / steps_count
550
+ # Press down to grab slider
551
+ page.input("Input.dispatchMouseEvent", {
552
+ "type": "mousePressed",
553
+ "x": start_x,
554
+ "y": start_y,
555
+ "button": "left",
556
+ "buttons": 1,
557
+ })
558
+ time.sleep(0.1)
559
+ # Move across with button held - many small steps
560
+ for step_i in range(steps_count):
561
+ x = start_x + (end_x - start_x) * (step_i / steps_count)
562
+ page.input("Input.dispatchMouseEvent", {
563
+ "type": "mouseMoved",
564
+ "x": int(x),
565
+ "y": start_y,
566
+ "buttons": 1,
567
+ })
568
+ time.sleep(step_duration)
569
+ # Release
570
+ page.input("Input.dispatchMouseEvent", {
571
+ "type": "mouseReleased",
572
+ "x": end_x,
573
+ "y": start_y,
574
+ "button": "left",
575
+ })
576
+ print(f" dragged {direction}")
571
577
  time.sleep(delay)
572
578
  print("flow complete")
573
579
  if spawned_ctx and temp.get("dispose"):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storyboard-bridge",
3
- "version": "0.9.39",
3
+ "version": "0.9.40",
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": {