@hypothesi/tauri-mcp-server 0.11.2 → 0.13.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.
@@ -1,76 +0,0 @@
1
- /**
2
- * Keyboard interaction scripts
3
- */
4
-
5
- /**
6
- * Type text into an element
7
- * @param {Object} params
8
- * @param {string} params.selector - CSS selector for the element
9
- * @param {string} params.text - Text to type
10
- */
11
- function typeText(params) {
12
- const { selector, text } = params;
13
-
14
- const element = document.querySelector(selector);
15
- if (!element) {
16
- throw new Error(`Element not found: ${selector}`);
17
- }
18
-
19
- // Focus the element
20
- element.focus();
21
-
22
- // Set the value
23
- element.value = text;
24
-
25
- // Trigger input event for frameworks that listen to it
26
- element.dispatchEvent(new Event('input', { bubbles: true }));
27
- element.dispatchEvent(new Event('change', { bubbles: true }));
28
-
29
- return `Typed "${text}" into ${selector}`;
30
- }
31
-
32
- /**
33
- * Send keyboard events (press, down, up)
34
- * @param {Object} params
35
- * @param {string} params.action - 'press', 'down', or 'up'
36
- * @param {string} params.key - Key to press
37
- * @param {string[]} params.modifiers - Modifier keys
38
- */
39
- function keyEvent(params) {
40
- const { action, key, modifiers } = params;
41
-
42
- const eventOptions = {
43
- key: key,
44
- code: key,
45
- bubbles: true,
46
- cancelable: true,
47
- ctrlKey: modifiers.includes('Control'),
48
- altKey: modifiers.includes('Alt'),
49
- shiftKey: modifiers.includes('Shift'),
50
- metaKey: modifiers.includes('Meta'),
51
- };
52
-
53
- const activeElement = document.activeElement || document.body;
54
-
55
- if (action === 'press') {
56
- activeElement.dispatchEvent(new KeyboardEvent('keydown', eventOptions));
57
- activeElement.dispatchEvent(new KeyboardEvent('keypress', eventOptions));
58
- activeElement.dispatchEvent(new KeyboardEvent('keyup', eventOptions));
59
- return `Pressed key: ${key}${modifiers.length ? ' with ' + modifiers.join('+') : ''}`;
60
- }
61
-
62
- if (action === 'down') {
63
- activeElement.dispatchEvent(new KeyboardEvent('keydown', eventOptions));
64
- return `Key down: ${key}${modifiers.length ? ' with ' + modifiers.join('+') : ''}`;
65
- }
66
-
67
- if (action === 'up') {
68
- activeElement.dispatchEvent(new KeyboardEvent('keyup', eventOptions));
69
- return `Key up: ${key}${modifiers.length ? ' with ' + modifiers.join('+') : ''}`;
70
- }
71
-
72
- throw new Error(`Unknown action: ${action}`);
73
- }
74
-
75
- // Export for use
76
- ({ typeText, keyEvent })