channel-worker 1.1.5 → 1.1.7
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.
- package/lib/command-poller.js +14 -3
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -631,7 +631,7 @@ class CommandPoller {
|
|
|
631
631
|
}
|
|
632
632
|
if (!el) return null;
|
|
633
633
|
const rect = el.getBoundingClientRect();
|
|
634
|
-
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
|
|
634
|
+
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2, tag: el.tagName, aria: (el.getAttribute('aria-label') || '').substring(0, 50), text: (el.textContent || '').trim().substring(0, 30) };
|
|
635
635
|
})()
|
|
636
636
|
`,
|
|
637
637
|
returnByValue: true,
|
|
@@ -643,7 +643,7 @@ class CommandPoller {
|
|
|
643
643
|
// Click with mouse
|
|
644
644
|
await send('Input.dispatchMouseEvent', { type: 'mousePressed', x: pos.x, y: pos.y, button: 'left', clickCount: 1 });
|
|
645
645
|
await send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: pos.x, y: pos.y, button: 'left', clickCount: 1 });
|
|
646
|
-
console.log(`[commands] Mouse clicked
|
|
646
|
+
console.log(`[commands] Mouse clicked at (${pos.x}, ${pos.y}) — ${pos.tag} "${pos.aria}" "${pos.text}"`);
|
|
647
647
|
|
|
648
648
|
// Wait for file chooser
|
|
649
649
|
const chooserResult = await chooserPromise;
|
|
@@ -695,7 +695,7 @@ class CommandPoller {
|
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
async handleTypeText(command) {
|
|
698
|
-
const { text, profile_id, url_match, focus_selector, press_enter } = command.payload || {};
|
|
698
|
+
const { text, profile_id, url_match, focus_selector, press_enter, select_all } = command.payload || {};
|
|
699
699
|
console.log(`[commands] Typing text (${text?.length} chars) for profile: ${profile_id}`);
|
|
700
700
|
try {
|
|
701
701
|
const WebSocket = require('ws');
|
|
@@ -783,6 +783,17 @@ class CommandPoller {
|
|
|
783
783
|
}
|
|
784
784
|
// Small delay for focus to take effect
|
|
785
785
|
await new Promise(r => setTimeout(r, 300));
|
|
786
|
+
// Select all existing text if requested (to clear/replace)
|
|
787
|
+
if (select_all) {
|
|
788
|
+
await send('Input.dispatchKeyEvent', { type: 'rawKeyDown', key: 'a', code: 'KeyA', windowsVirtualKeyCode: 65, nativeVirtualKeyCode: 65, modifiers: 2 }); // Ctrl+A
|
|
789
|
+
await send('Input.dispatchKeyEvent', { type: 'keyUp', key: 'a', code: 'KeyA', windowsVirtualKeyCode: 65, nativeVirtualKeyCode: 65, modifiers: 2 });
|
|
790
|
+
await new Promise(r => setTimeout(r, 200));
|
|
791
|
+
// Delete selected
|
|
792
|
+
await send('Input.dispatchKeyEvent', { type: 'rawKeyDown', key: 'Backspace', code: 'Backspace', windowsVirtualKeyCode: 8, nativeVirtualKeyCode: 8 });
|
|
793
|
+
await send('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Backspace', code: 'Backspace', windowsVirtualKeyCode: 8, nativeVirtualKeyCode: 8 });
|
|
794
|
+
await new Promise(r => setTimeout(r, 200));
|
|
795
|
+
}
|
|
796
|
+
|
|
786
797
|
// Type text — use char-by-char for inputs that need keystroke events (press_enter mode)
|
|
787
798
|
if (press_enter) {
|
|
788
799
|
// Type each character with delay so React processes keystrokes
|