ia_rewrite_ntapp 1.0.8 → 1.0.9
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/index.js +10 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -51,6 +51,10 @@ async function readClipboard() {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
function normalizeClipboardText(value) {
|
|
55
|
+
return String(value ?? "").replace(/\r\n/g, "\n");
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
async function readClipboardWithRetry(previousValue, maxWaitMs = 1500) {
|
|
55
59
|
const start = Date.now();
|
|
56
60
|
let current = await readClipboard();
|
|
@@ -81,18 +85,19 @@ async function writeClipboard(text) {
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
async function writeClipboardWithVerify(text, maxWaitMs = 1500) {
|
|
88
|
+
const expected = normalizeClipboardText(text);
|
|
84
89
|
await writeClipboard(text);
|
|
85
90
|
const start = Date.now();
|
|
86
|
-
let current = await readClipboard();
|
|
91
|
+
let current = normalizeClipboardText(await readClipboard());
|
|
87
92
|
while (Date.now() - start < maxWaitMs) {
|
|
88
|
-
if (current ===
|
|
93
|
+
if (current === expected) return true;
|
|
89
94
|
await new Promise((r) => setTimeout(r, 100));
|
|
90
|
-
current = await readClipboard();
|
|
95
|
+
current = normalizeClipboardText(await readClipboard());
|
|
91
96
|
}
|
|
92
97
|
// força fallback se não confirmou
|
|
93
98
|
writeClipboardFallback(text);
|
|
94
|
-
current = await
|
|
95
|
-
return current ===
|
|
99
|
+
current = normalizeClipboardText(await readClipboardFallback());
|
|
100
|
+
return current === expected;
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
function loadConfig() {
|