@1presence/speech 1.1.0 → 1.2.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.
- package/package.json +1 -1
- package/public/index.html +4 -1
- package/server.mjs +13 -2
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -192,8 +192,11 @@
|
|
|
192
192
|
|
|
193
193
|
// Display keeps paragraph breaks; app/terminal delivery must be one line so
|
|
194
194
|
// paste guards (iTerm) do not treat newlines as a multi-line paste.
|
|
195
|
+
// Do not trim — live chunks often start with a leading space from getStreamSeparator.
|
|
195
196
|
function formatTextForAppSend(text) {
|
|
196
|
-
return
|
|
197
|
+
return String(text || "")
|
|
198
|
+
.replace(/\n+/g, " ")
|
|
199
|
+
.replace(/[^\S\n]+/g, " ");
|
|
197
200
|
}
|
|
198
201
|
|
|
199
202
|
function capitalizeFirstWord(text) {
|
package/server.mjs
CHANGED
|
@@ -74,11 +74,22 @@ end run
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
function typeIntoFocusedApp(text, pressEnter) {
|
|
77
|
+
// System Events often drops literal spaces inside keystroke strings from Node.
|
|
78
|
+
// Type each character and use keystroke space for space characters.
|
|
77
79
|
const script = `
|
|
78
80
|
on run argv
|
|
81
|
+
set inputText to item 1 of argv
|
|
82
|
+
set pressEnter to item 2 of argv
|
|
79
83
|
tell application "System Events"
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
repeat with i from 1 to count of characters of inputText
|
|
85
|
+
set ch to character i of inputText
|
|
86
|
+
if ch is " " then
|
|
87
|
+
keystroke space
|
|
88
|
+
else
|
|
89
|
+
keystroke ch
|
|
90
|
+
end if
|
|
91
|
+
end repeat
|
|
92
|
+
if pressEnter is "true" then
|
|
82
93
|
key code 36
|
|
83
94
|
end if
|
|
84
95
|
end tell
|