node-mac-recorder 2.22.22 → 2.22.24
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.
|
@@ -105,39 +105,8 @@ function transformInputFrameGlobal(ifr, d) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
// Electron: AX caret cache — deferred refresh ile crash-safe
|
|
109
|
-
const ELECTRON_AX_CACHE_MAX_AGE_MS = 500;
|
|
110
|
-
|
|
111
|
-
function deferredRefreshElectronAXCache(recorder, nativeBinding) {
|
|
112
|
-
if (recorder._axDeferredPending) return;
|
|
113
|
-
if (!nativeBinding || typeof nativeBinding.getTextInputSnapshot !== "function") return;
|
|
114
|
-
|
|
115
|
-
recorder._axDeferredPending = true;
|
|
116
|
-
setImmediate(() => {
|
|
117
|
-
recorder._axDeferredPending = false;
|
|
118
|
-
try {
|
|
119
|
-
const snap = nativeBinding.getTextInputSnapshot();
|
|
120
|
-
if (snap && Number.isFinite(snap.caretX) && Number.isFinite(snap.caretY)) {
|
|
121
|
-
const d = recorder.cursorDisplayInfo;
|
|
122
|
-
const caretT = transformGlobalToVideo(snap.caretX, snap.caretY, d);
|
|
123
|
-
recorder._axCaretCache = {
|
|
124
|
-
caretX: caretT.x,
|
|
125
|
-
caretY: caretT.y,
|
|
126
|
-
inputFrame: snap.inputFrame
|
|
127
|
-
? transformInputFrameGlobal(snap.inputFrame, d)
|
|
128
|
-
: null,
|
|
129
|
-
csys: d && d.videoRelative ? "video-relative" : "global",
|
|
130
|
-
wallMs: Date.now(),
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
} catch {
|
|
134
|
-
// AX API hata verirse mevcut cache'i koru
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
108
|
/** @returns {boolean} Dosyaya textInput satırı yazıldı mı */
|
|
140
|
-
function tryAppendSyntheticTextInputRow(recorder,
|
|
109
|
+
function tryAppendSyntheticTextInputRow(recorder, filepath, cursorData, timestamp) {
|
|
141
110
|
if (!IS_ELECTRON) {
|
|
142
111
|
return false;
|
|
143
112
|
}
|
|
@@ -153,8 +122,6 @@ function tryAppendSyntheticTextInputRow(recorder, nativeBinding, filepath, curso
|
|
|
153
122
|
wall - (recorder._electronSynthWallMs || 0) <
|
|
154
123
|
ELECTRON_SYNTH_THROTTLE_MS
|
|
155
124
|
) {
|
|
156
|
-
// Throttle aktif olsa bile AX cache yenilensin
|
|
157
|
-
deferredRefreshElectronAXCache(recorder, nativeBinding);
|
|
158
125
|
return false;
|
|
159
126
|
}
|
|
160
127
|
const vx = cursorData.x;
|
|
@@ -163,28 +130,6 @@ function tryAppendSyntheticTextInputRow(recorder, nativeBinding, filepath, curso
|
|
|
163
130
|
return false;
|
|
164
131
|
}
|
|
165
132
|
|
|
166
|
-
// Cached AX caret varsa gerçek caret pozisyonunu kullan
|
|
167
|
-
let caretX = vx;
|
|
168
|
-
let caretY = vy;
|
|
169
|
-
let inputFrame = { x: vx - 1, y: vy - 9, width: 2, height: 18 };
|
|
170
|
-
let coordinateSystem = cursorData.coordinateSystem;
|
|
171
|
-
|
|
172
|
-
const cache = recorder._axCaretCache;
|
|
173
|
-
if (
|
|
174
|
-
cache &&
|
|
175
|
-
Number.isFinite(cache.caretX) &&
|
|
176
|
-
Number.isFinite(cache.caretY) &&
|
|
177
|
-
(wall - (cache.wallMs || 0)) < ELECTRON_AX_CACHE_MAX_AGE_MS
|
|
178
|
-
) {
|
|
179
|
-
caretX = cache.caretX;
|
|
180
|
-
caretY = cache.caretY;
|
|
181
|
-
if (cache.inputFrame) inputFrame = cache.inputFrame;
|
|
182
|
-
coordinateSystem = cache.csys || coordinateSystem;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Sonraki frame için AX cache'i yenile (deferred — crash-safe)
|
|
186
|
-
deferredRefreshElectronAXCache(recorder, nativeBinding);
|
|
187
|
-
|
|
188
133
|
const tiRow = {
|
|
189
134
|
x: vx,
|
|
190
135
|
y: vy,
|
|
@@ -192,10 +137,15 @@ function tryAppendSyntheticTextInputRow(recorder, nativeBinding, filepath, curso
|
|
|
192
137
|
unixTimeMs: wall,
|
|
193
138
|
cursorType: "text",
|
|
194
139
|
type: "textInput",
|
|
195
|
-
caretX,
|
|
196
|
-
caretY,
|
|
197
|
-
inputFrame
|
|
198
|
-
|
|
140
|
+
caretX: vx,
|
|
141
|
+
caretY: vy,
|
|
142
|
+
inputFrame: {
|
|
143
|
+
x: vx - 1,
|
|
144
|
+
y: vy - 9,
|
|
145
|
+
width: 2,
|
|
146
|
+
height: 18,
|
|
147
|
+
},
|
|
148
|
+
coordinateSystem: cursorData.coordinateSystem,
|
|
199
149
|
recordingType: cursorData.recordingType,
|
|
200
150
|
videoInfo: cursorData.videoInfo || {},
|
|
201
151
|
displayInfo: cursorData.displayInfo || {},
|
|
@@ -567,7 +517,6 @@ async function startCursorCapture(recorder, nativeBinding, intervalOrFilepath, o
|
|
|
567
517
|
if (IS_ELECTRON) {
|
|
568
518
|
const textInputWritten = tryAppendSyntheticTextInputRow(
|
|
569
519
|
recorder,
|
|
570
|
-
nativeBinding,
|
|
571
520
|
filepath,
|
|
572
521
|
cursorData,
|
|
573
522
|
timestamp,
|
package/package.json
CHANGED
|
@@ -502,7 +502,8 @@ extern "C" bool stopAVFoundationRecording() {
|
|
|
502
502
|
|
|
503
503
|
// Finish writing with null checks
|
|
504
504
|
AVAssetWriterInput *writerInput = g_avVideoInput;
|
|
505
|
-
|
|
505
|
+
AVAssetWriter *writerRef = g_avWriter;
|
|
506
|
+
if (writerInput && writerRef && writerRef.status == AVAssetWriterStatusWriting) {
|
|
506
507
|
[writerInput markAsFinished];
|
|
507
508
|
}
|
|
508
509
|
|
|
@@ -342,17 +342,23 @@ static void FinishWriter(AVAssetWriter *writer, AVAssetWriterInput *input) {
|
|
|
342
342
|
if (!writer) {
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
|
|
346
|
+
// markAsFinished sadece AVAssetWriterStatusWriting (1) durumunda çağrılabilir
|
|
347
|
+
// Status 0 (Unknown) veya diğer durumlarda crash eder
|
|
348
|
+
if (input && writer.status == AVAssetWriterStatusWriting) {
|
|
347
349
|
[input markAsFinished];
|
|
348
350
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
351
|
+
|
|
352
|
+
if (writer.status == AVAssetWriterStatusWriting) {
|
|
353
|
+
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
354
|
+
[writer finishWritingWithCompletionHandler:^{
|
|
355
|
+
dispatch_semaphore_signal(semaphore);
|
|
356
|
+
}];
|
|
357
|
+
dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC));
|
|
358
|
+
dispatch_semaphore_wait(semaphore, timeout);
|
|
359
|
+
} else if (writer.status == AVAssetWriterStatusFailed) {
|
|
360
|
+
NSLog(@"⚠️ Writer already failed: %@", writer.error);
|
|
361
|
+
}
|
|
356
362
|
}
|
|
357
363
|
|
|
358
364
|
static void CleanupWriters(void) {
|
|
@@ -373,10 +379,10 @@ static void CleanupWriters(void) {
|
|
|
373
379
|
}
|
|
374
380
|
|
|
375
381
|
if (g_audioWriter) {
|
|
376
|
-
if (g_systemAudioInput) {
|
|
382
|
+
if (g_systemAudioInput && g_audioWriter.status == AVAssetWriterStatusWriting) {
|
|
377
383
|
[g_systemAudioInput markAsFinished];
|
|
378
384
|
}
|
|
379
|
-
if (g_microphoneAudioInput) {
|
|
385
|
+
if (g_microphoneAudioInput && g_audioWriter.status == AVAssetWriterStatusWriting) {
|
|
380
386
|
[g_microphoneAudioInput markAsFinished];
|
|
381
387
|
}
|
|
382
388
|
FinishWriter(g_audioWriter, nil);
|