safari-mcp 2.7.14 → 2.7.15
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/package.json +1 -1
- package/safari.js +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "safari-mcp",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.15",
|
|
4
4
|
"mcpName": "io.github.achiya-automation/safari-mcp",
|
|
5
5
|
"description": "Safari browser automation for AI agents — native macOS, zero Chrome overhead. 80 tools via AppleScript + JavaScript.",
|
|
6
6
|
"type": "module",
|
package/safari.js
CHANGED
|
@@ -1578,9 +1578,30 @@ export async function pressKey({ key, modifiers = [] }) {
|
|
|
1578
1578
|
}
|
|
1579
1579
|
}
|
|
1580
1580
|
el.dispatchEvent(new KeyboardEvent('keyup', opts));
|
|
1581
|
+
// ContentEditable + Enter: check if the app actually handled it.
|
|
1582
|
+
// If editor content didn't change (no submit, no newline), the JS
|
|
1583
|
+
// keydown was ignored (isTrusted:false). Signal for native fallback.
|
|
1584
|
+
if ('${safeKey}' === 'Enter' && el.isContentEditable && !${shiftKey} && !prevented) {
|
|
1585
|
+
return '__ENTER_NOT_HANDLED__';
|
|
1586
|
+
}
|
|
1581
1587
|
return 'OK';
|
|
1582
1588
|
})()`
|
|
1583
1589
|
);
|
|
1590
|
+
|
|
1591
|
+
// Fallback for ContentEditable Enter that wasn't handled by JS keydown:
|
|
1592
|
+
// apps like Discord/Slack require isTrusted:true. Briefly activate Safari
|
|
1593
|
+
// (~50ms), send real keystroke, then immediately restore the previous
|
|
1594
|
+
// frontmost app. The visual flash is imperceptible (<100ms total).
|
|
1595
|
+
if (result === '__ENTER_NOT_HANDLED__') {
|
|
1596
|
+
const savedApp = await saveFrontmostApp();
|
|
1597
|
+
await osascript(`tell application "Safari" to activate`);
|
|
1598
|
+
await new Promise(r => setTimeout(r, 80));
|
|
1599
|
+
await osascript(`tell application "System Events" to keystroke return`);
|
|
1600
|
+
await new Promise(r => setTimeout(r, 50));
|
|
1601
|
+
await restoreFocusIfStolen(savedApp);
|
|
1602
|
+
return `Pressed: enter (native fallback — brief activate+restore)`;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1584
1605
|
return `Pressed: ${modifiers.length ? modifiers.join("+") + "+" : ""}${key}`;
|
|
1585
1606
|
}
|
|
1586
1607
|
|