node-mac-recorder 2.1.2 → 2.2.1

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/test-audio.js ADDED
@@ -0,0 +1,94 @@
1
+ const MacRecorder = require('./index');
2
+
3
+ function testAudioCapture() {
4
+ console.log('šŸŽµ Testing ScreenCaptureKit Audio Capture...\n');
5
+
6
+ const recorder = new MacRecorder();
7
+ let testCompleted = false;
8
+
9
+ // Set timeout to prevent hanging
10
+ setTimeout(() => {
11
+ if (!testCompleted) {
12
+ console.log('āš ļø Test timed out after 10 seconds');
13
+ process.exit(0);
14
+ }
15
+ }, 10000);
16
+
17
+ try {
18
+ console.log('šŸ“± Testing audio device enumeration...');
19
+
20
+ // Test audio device enumeration - this should work without permissions
21
+ const startTime = Date.now();
22
+
23
+ recorder.getAudioDevices((err, audioDevices) => {
24
+ const elapsed = Date.now() - startTime;
25
+ console.log(`ā±ļø getAudioDevices took ${elapsed}ms`);
26
+
27
+ if (err) {
28
+ console.error('āŒ getAudioDevices failed:', err);
29
+ testCompleted = true;
30
+ return;
31
+ }
32
+
33
+ console.log(`āœ… Found ${audioDevices.length} audio devices:`);
34
+
35
+ audioDevices.slice(0, 5).forEach((device, index) => {
36
+ console.log(`${index + 1}. "${device.name}" (${device.manufacturer || 'Unknown'})`);
37
+ console.log(` ID: ${device.id}`);
38
+ console.log(` Default: ${device.isDefault ? 'Yes' : 'No'}`);
39
+ if (device.isSystemDevice) {
40
+ console.log(` System Device: ${device.isSystemDevice ? 'Yes' : 'No'}`);
41
+ }
42
+ console.log('');
43
+ });
44
+
45
+ // Test permissions
46
+ console.log('šŸ” Testing audio permissions...');
47
+
48
+ recorder.checkPermissions((err, hasPermissions) => {
49
+ const elapsed2 = Date.now() - startTime;
50
+ console.log(`ā±ļø checkPermissions took ${elapsed2 - elapsed}ms`);
51
+
52
+ if (err) {
53
+ console.error('āŒ checkPermissions failed:', err);
54
+ } else {
55
+ console.log(`āœ… Permissions status: ${hasPermissions ? 'Granted' : 'Not granted'}`);
56
+ }
57
+
58
+ // Test microphone-specific features if available
59
+ if (audioDevices.length > 0) {
60
+ const micDevice = audioDevices.find(d => d.isDefault && !d.isSystemDevice);
61
+ const systemDevice = audioDevices.find(d => d.isSystemDevice);
62
+
63
+ if (micDevice) {
64
+ console.log(`šŸŽ¤ Default microphone: "${micDevice.name}"`);
65
+ console.log(` This would be used for includeMicrophone: true`);
66
+ }
67
+
68
+ if (systemDevice) {
69
+ console.log(`šŸ”Š System audio device found: "${systemDevice.name}"`);
70
+ console.log(` This would be used for includeSystemAudio: true`);
71
+ } else {
72
+ console.log('āš ļø No system audio device detected');
73
+ console.log(' For system audio capture, consider installing BlackHole or similar');
74
+ }
75
+ }
76
+
77
+ console.log('\nāœ… Audio capture tests completed successfully!');
78
+ console.log('\nšŸ“ Audio Configuration Summary:');
79
+ console.log(` • Total audio devices: ${audioDevices.length}`);
80
+ console.log(` • Microphone devices: ${audioDevices.filter(d => !d.isSystemDevice).length}`);
81
+ console.log(` • System audio devices: ${audioDevices.filter(d => d.isSystemDevice).length}`);
82
+ console.log(` • Permissions: ${hasPermissions ? 'āœ… Granted' : 'āŒ Need to grant'}`);
83
+
84
+ testCompleted = true;
85
+ });
86
+ });
87
+
88
+ } catch (error) {
89
+ console.error('āŒ Audio capture test failed:', error);
90
+ testCompleted = true;
91
+ }
92
+ }
93
+
94
+ testAudioCapture();
@@ -0,0 +1,164 @@
1
+ const MacRecorder = require('./index');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ function runComprehensiveTests() {
6
+ console.log('🧪 Running Comprehensive ScreenCaptureKit Tests\n');
7
+ console.log('=' .repeat(60));
8
+
9
+ const recorder = new MacRecorder();
10
+ let testResults = {
11
+ passed: 0,
12
+ failed: 0,
13
+ details: []
14
+ };
15
+
16
+ function addResult(testName, passed, details = '') {
17
+ testResults.details.push({
18
+ name: testName,
19
+ passed,
20
+ details
21
+ });
22
+
23
+ if (passed) {
24
+ testResults.passed++;
25
+ console.log(`āœ… ${testName}`);
26
+ } else {
27
+ testResults.failed++;
28
+ console.log(`āŒ ${testName}: ${details}`);
29
+ }
30
+ if (details && passed) {
31
+ console.log(` ${details}`);
32
+ }
33
+ }
34
+
35
+ // Test 1: Module Loading
36
+ try {
37
+ addResult('Module Loading', true, 'MacRecorder class instantiated successfully');
38
+ } catch (error) {
39
+ addResult('Module Loading', false, error.message);
40
+ }
41
+
42
+ // Test 2: Method Availability
43
+ const expectedMethods = [
44
+ 'getDisplays', 'getWindows', 'getAudioDevices', 'startRecording',
45
+ 'stopRecording', 'checkPermissions', 'getCursorPosition',
46
+ 'getWindowThumbnail', 'getDisplayThumbnail'
47
+ ];
48
+
49
+ let missingMethods = [];
50
+ expectedMethods.forEach(method => {
51
+ if (typeof recorder[method] !== 'function') {
52
+ missingMethods.push(method);
53
+ }
54
+ });
55
+
56
+ if (missingMethods.length === 0) {
57
+ addResult('API Method Availability', true, `All ${expectedMethods.length} expected methods available`);
58
+ } else {
59
+ addResult('API Method Availability', false, `Missing methods: ${missingMethods.join(', ')}`);
60
+ }
61
+
62
+ // Test 3: Synchronous Operations
63
+ try {
64
+ const cursor = recorder.getCurrentCursorPosition();
65
+ if (cursor && typeof cursor.x === 'number' && typeof cursor.y === 'number') {
66
+ addResult('Cursor Position (Sync)', true, `Position: (${cursor.x}, ${cursor.y}), Type: ${cursor.cursorType}`);
67
+ } else {
68
+ addResult('Cursor Position (Sync)', false, 'Invalid cursor data returned');
69
+ }
70
+ } catch (error) {
71
+ addResult('Cursor Position (Sync)', false, error.message);
72
+ }
73
+
74
+ // Test 4: Cursor Capture Status
75
+ try {
76
+ const status = recorder.getCursorCaptureStatus();
77
+ addResult('Cursor Capture Status', true, `Tracking: ${status.isTracking || false}`);
78
+ } catch (error) {
79
+ addResult('Cursor Capture Status', false, error.message);
80
+ }
81
+
82
+ console.log('\n' + '─'.repeat(60));
83
+ console.log('šŸ“Š Test Results Summary:');
84
+ console.log('─'.repeat(60));
85
+ console.log(`āœ… Passed: ${testResults.passed}`);
86
+ console.log(`āŒ Failed: ${testResults.failed}`);
87
+ console.log(`šŸ“ˆ Success Rate: ${Math.round((testResults.passed / (testResults.passed + testResults.failed)) * 100)}%`);
88
+
89
+ console.log('\nšŸ” Detailed Analysis:');
90
+ console.log('─'.repeat(60));
91
+
92
+ // Test async operations with timeout
93
+ console.log('\nšŸ”„ Testing Async Operations (with 8s timeout each):');
94
+
95
+ let asyncTests = 0;
96
+ let asyncPassed = 0;
97
+
98
+ function testAsync(testName, asyncFunction, timeout = 8000) {
99
+ return new Promise((resolve) => {
100
+ asyncTests++;
101
+ const timeoutId = setTimeout(() => {
102
+ console.log(`āš ļø ${testName}: Timed out after ${timeout/1000}s (likely permission dialog)`);
103
+ resolve(false);
104
+ }, timeout);
105
+
106
+ try {
107
+ asyncFunction((error, result) => {
108
+ clearTimeout(timeoutId);
109
+ if (error) {
110
+ console.log(`āŒ ${testName}: ${error.message || error}`);
111
+ resolve(false);
112
+ } else {
113
+ const resultInfo = Array.isArray(result) ? `${result.length} items` : 'Success';
114
+ console.log(`āœ… ${testName}: ${resultInfo}`);
115
+ asyncPassed++;
116
+ resolve(true);
117
+ }
118
+ });
119
+ } catch (error) {
120
+ clearTimeout(timeoutId);
121
+ console.log(`āŒ ${testName}: ${error.message}`);
122
+ resolve(false);
123
+ }
124
+ });
125
+ }
126
+
127
+ // Run async tests sequentially
128
+ (async () => {
129
+ await testAsync('Permissions Check', (cb) => recorder.checkPermissions(cb));
130
+ await testAsync('Display Enumeration', (cb) => recorder.getDisplays(cb));
131
+ await testAsync('Window Enumeration', (cb) => recorder.getWindows(cb));
132
+ await testAsync('Audio Device Enumeration', (cb) => recorder.getAudioDevices(cb));
133
+
134
+ console.log('\n' + '═'.repeat(60));
135
+ console.log('šŸ Final Test Summary:');
136
+ console.log('═'.repeat(60));
137
+ console.log(`šŸ”§ Synchronous Tests: ${testResults.passed}/${testResults.passed + testResults.failed} passed`);
138
+ console.log(`šŸ”„ Asynchronous Tests: ${asyncPassed}/${asyncTests} passed`);
139
+ console.log(`šŸ“Š Overall: ${testResults.passed + asyncPassed}/${testResults.passed + testResults.failed + asyncTests} tests passed`);
140
+
141
+ const overallSuccess = Math.round(((testResults.passed + asyncPassed) / (testResults.passed + testResults.failed + asyncTests)) * 100);
142
+
143
+ if (overallSuccess >= 80) {
144
+ console.log(`\nšŸŽ‰ ScreenCaptureKit Migration: ${overallSuccess}% SUCCESS!`);
145
+ console.log('✨ The migration is working correctly');
146
+ } else if (overallSuccess >= 60) {
147
+ console.log(`\nāš ļø ScreenCaptureKit Migration: ${overallSuccess}% PARTIAL SUCCESS`);
148
+ console.log('šŸ”§ Some functionality working, permissions may need attention');
149
+ } else {
150
+ console.log(`\nāŒ ScreenCaptureKit Migration: ${overallSuccess}% - NEEDS WORK`);
151
+ console.log('🚨 Multiple issues detected');
152
+ }
153
+
154
+ console.log('\nšŸ’” Notes:');
155
+ console.log('• Timeouts usually indicate missing screen recording permissions');
156
+ console.log('• Enable permissions in: System Preferences > Privacy & Security > Screen Recording');
157
+ console.log('• ScreenCaptureKit requires macOS 12.3+ and arm64 architecture');
158
+ console.log('• All synchronous operations (cursor tracking) should work without permissions');
159
+
160
+ process.exit(0);
161
+ })();
162
+ }
163
+
164
+ runComprehensiveTests();
@@ -0,0 +1,142 @@
1
+ const MacRecorder = require("./index");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+
5
+ async function testRecording() {
6
+ console.log("šŸŽ¬ Testing ScreenCaptureKit Recording...\n");
7
+
8
+ const recorder = new MacRecorder();
9
+ const outputDir = path.join(__dirname, "test-output");
10
+
11
+ // Create test output directory
12
+ if (!fs.existsSync(outputDir)) {
13
+ fs.mkdirSync(outputDir);
14
+ console.log("šŸ“ Created test-output directory");
15
+ }
16
+
17
+ const outputFile = path.resolve(outputDir, "sck-test-recording.mov");
18
+ console.log(`šŸ“¹ Output file: ${outputFile}`);
19
+
20
+ // Test recording options
21
+ const recordingOptions = {
22
+ captureCursor: true,
23
+ excludeCurrentApp: true,
24
+ includeMicrophone: true,
25
+ includeSystemAudio: true, // Disable to avoid permission issues for now
26
+ displayId: null, // Will use main display
27
+ };
28
+
29
+ console.log(
30
+ "šŸ“ Recording options:",
31
+ JSON.stringify(recordingOptions, null, 2)
32
+ );
33
+ console.log("\nšŸš€ Starting recording test...");
34
+
35
+ try {
36
+ // Test current cursor position before recording
37
+ const cursor = recorder.getCurrentCursorPosition();
38
+ console.log(
39
+ `šŸ–±ļø Current cursor: x=${cursor.x}, y=${cursor.y}, type=${cursor.cursorType}`
40
+ );
41
+
42
+ // Determine a window to exclude (prefer a window with name containing "Cursor")
43
+ try {
44
+ const windows = await recorder.getWindows();
45
+ if (Array.isArray(windows) && windows.length) {
46
+ const pick =
47
+ windows.find(
48
+ (w) =>
49
+ (typeof w.appName === "string" && /cursor/i.test(w.appName)) ||
50
+ (typeof w.name === "string" && /cursor/i.test(w.name)) ||
51
+ (typeof w.title === "string" && /cursor/i.test(w.title))
52
+ ) || windows[0];
53
+ const wid = pick?.id ?? pick?.windowId ?? pick?.windowID ?? null;
54
+ if (wid != null) {
55
+ recordingOptions.excludeWindowIds = [Number(wid)];
56
+ }
57
+ }
58
+ } catch (_) {}
59
+
60
+ // Start recording
61
+ console.log("ā–¶ļø Attempting to start recording...");
62
+
63
+ // Start recording without callback first
64
+ console.log("šŸ” Attempting startRecording without callback...");
65
+
66
+ let startResult;
67
+ try {
68
+ startResult = await recorder.startRecording(outputFile, recordingOptions);
69
+ console.log(`šŸ“Š startRecording resolved: ${startResult}`);
70
+ } catch (error) {
71
+ console.error("āŒ startRecording threw error:", error.message);
72
+ console.error("Stack:", error.stack);
73
+ return;
74
+ }
75
+
76
+ if (startResult) {
77
+ console.log("āœ… Recording started successfully");
78
+ console.log("ā±ļø Recording for 3 seconds...");
79
+
80
+ // Record for ~6 seconds
81
+ setTimeout(async () => {
82
+ console.log("ā¹ļø Stopping recording...");
83
+
84
+ let stopResult;
85
+ try {
86
+ stopResult = await recorder.stopRecording();
87
+ console.log(
88
+ `šŸ“Š stopRecording resolved: ${JSON.stringify(stopResult)}`
89
+ );
90
+
91
+ if (stopResult && stopResult.code === 0) {
92
+ console.log("āœ… Stop recording command sent");
93
+ } else {
94
+ console.log("āŒ Failed to send stop recording command");
95
+ }
96
+ } catch (error) {
97
+ console.error("āŒ stopRecording threw error:", error.message);
98
+ console.error("Stack:", error.stack);
99
+ }
100
+
101
+ // Final check after a longer delay
102
+ setTimeout(() => {
103
+ console.log("\nšŸ“Š Final Results:");
104
+
105
+ try {
106
+ if (fs.existsSync(outputFile)) {
107
+ const stats = fs.statSync(outputFile);
108
+ console.log(`āœ… Recording file exists: ${stats.size} bytes`);
109
+ console.log(`šŸ“ Location: ${outputFile}`);
110
+ console.log("šŸŽÆ ScreenCaptureKit recording test PASSED");
111
+ } else {
112
+ console.log("āŒ Recording file does not exist");
113
+ console.log(
114
+ "šŸ” This might be due to permissions or ScreenCaptureKit configuration"
115
+ );
116
+ }
117
+ } catch (error) {
118
+ console.error("āŒ Final check error:", error.message);
119
+ }
120
+
121
+ console.log("\nāœ… Recording test completed");
122
+ }, 4000);
123
+ }, 6000);
124
+ } else {
125
+ console.log("āŒ Failed to start recording");
126
+ console.log("šŸ” Possible causes:");
127
+ console.log(" • Screen recording permissions not granted");
128
+ console.log(" • ScreenCaptureKit not available (requires macOS 12.3+)");
129
+ console.log(" • Display/window selection issues");
130
+ }
131
+ } catch (error) {
132
+ console.error("āŒ Recording test failed with exception:", error);
133
+ }
134
+ }
135
+
136
+ // Handle process exit
137
+ process.on("SIGINT", () => {
138
+ console.log("\nāš ļø Recording test interrupted");
139
+ process.exit(0);
140
+ });
141
+
142
+ testRecording();
@@ -0,0 +1,37 @@
1
+ const MacRecorder = require('./index');
2
+
3
+ async function testScreenCaptureKit() {
4
+ console.log('Testing ScreenCaptureKit migration...');
5
+
6
+ const recorder = new MacRecorder();
7
+
8
+ try {
9
+ // Test 1: Check permissions
10
+ console.log('\n1. Testing checkPermissions()');
11
+ const permissions = await recorder.checkPermissions();
12
+ console.log('āœ… Permissions:', permissions);
13
+
14
+ // Test 2: Get displays
15
+ console.log('\n2. Testing getDisplays()');
16
+ const displays = await recorder.getDisplays();
17
+ console.log(`āœ… Found ${displays.length} displays:`, displays.map(d => `${d.id}:${d.width}x${d.height}`));
18
+
19
+ // Test 3: Get windows
20
+ console.log('\n3. Testing getWindows()');
21
+ const windows = await recorder.getWindows();
22
+ console.log(`āœ… Found ${windows.length} windows:`, windows.slice(0, 3).map(w => `${w.id}:"${w.title}"`));
23
+
24
+ // Test 4: Get audio devices
25
+ console.log('\n4. Testing getAudioDevices()');
26
+ const audioDevices = await recorder.getAudioDevices();
27
+ console.log(`āœ… Found ${audioDevices.length} audio devices:`, audioDevices.slice(0, 3).map(d => `${d.id}:"${d.name}"`));
28
+
29
+ console.log('\nšŸŽ‰ All ScreenCaptureKit tests passed!');
30
+ console.log('\nāœ… ScreenCaptureKit migration successful!');
31
+
32
+ } catch (error) {
33
+ console.error('āŒ Test failed:', error);
34
+ }
35
+ }
36
+
37
+ testScreenCaptureKit();
package/test-sck.js ADDED
@@ -0,0 +1,109 @@
1
+ <<<<<<< HEAD
2
+ const nativeBinding = require('./build/Release/mac_recorder.node');
3
+
4
+ console.log('=== ScreenCaptureKit Migration Test ===');
5
+ console.log('ScreenCaptureKit available:', nativeBinding.isScreenCaptureKitAvailable());
6
+ console.log('Displays:', nativeBinding.getDisplays().length);
7
+ console.log('Audio devices:', nativeBinding.getAudioDevices().length);
8
+ console.log('Permissions OK:', nativeBinding.checkPermissions());
9
+
10
+ const displays = nativeBinding.getDisplays();
11
+ console.log('\nDisplay info:', displays[0]);
12
+
13
+ const audioDevices = nativeBinding.getAudioDevices();
14
+ console.log('\nFirst audio device:', audioDevices[0]);
15
+
16
+ // Test starting and stopping recording
17
+ console.log('\n=== Recording Test ===');
18
+ const outputPath = '/tmp/test-recording-sck.mov';
19
+
20
+ try {
21
+ console.log('Starting recording...');
22
+ const success = nativeBinding.startRecording(outputPath, {
23
+ displayId: displays[0].id,
24
+ captureCursor: true,
25
+ includeMicrophone: false,
26
+ includeSystemAudio: false
27
+ });
28
+
29
+ console.log('Recording started:', success);
30
+
31
+ if (success) {
32
+ setTimeout(() => {
33
+ console.log('Stopping recording...');
34
+ const stopped = nativeBinding.stopRecording();
35
+ console.log('Recording stopped:', stopped);
36
+
37
+ // Check if file was created
38
+ const fs = require('fs');
39
+ setTimeout(() => {
40
+ if (fs.existsSync(outputPath)) {
41
+ const stats = fs.statSync(outputPath);
42
+ console.log(`Recording file created: ${outputPath} (${stats.size} bytes)`);
43
+ } else {
44
+ console.log('Recording file not found');
45
+ }
46
+ }, 1000);
47
+ }, 3000); // Record for 3 seconds
48
+ }
49
+ } catch (error) {
50
+ console.error('Recording test failed:', error.message);
51
+ }
52
+ =======
53
+ const MacRecorder = require('./index');
54
+
55
+ function testScreenCaptureKit() {
56
+ console.log('Testing ScreenCaptureKit migration...');
57
+
58
+ const recorder = new MacRecorder();
59
+
60
+ try {
61
+ // Test getting displays
62
+ console.log('\n1. Testing getDisplays()');
63
+ recorder.getDisplays((err, displays) => {
64
+ if (err) {
65
+ console.error('getDisplays failed:', err);
66
+ return;
67
+ }
68
+ console.log(`Found ${displays.length} displays:`, displays);
69
+
70
+ // Test getting windows
71
+ console.log('\n2. Testing getWindows()');
72
+ recorder.getWindows((err, windows) => {
73
+ if (err) {
74
+ console.error('getWindows failed:', err);
75
+ return;
76
+ }
77
+ console.log(`Found ${windows.length} windows:`, windows.slice(0, 3));
78
+
79
+ // Test getting audio devices
80
+ console.log('\n3. Testing getAudioDevices()');
81
+ recorder.getAudioDevices((err, audioDevices) => {
82
+ if (err) {
83
+ console.error('getAudioDevices failed:', err);
84
+ return;
85
+ }
86
+ console.log(`Found ${audioDevices.length} audio devices:`, audioDevices.slice(0, 3));
87
+
88
+ // Test permissions
89
+ console.log('\n4. Testing checkPermissions()');
90
+ recorder.checkPermissions((err, hasPermissions) => {
91
+ if (err) {
92
+ console.error('checkPermissions failed:', err);
93
+ return;
94
+ }
95
+ console.log(`Has permissions: ${hasPermissions}`);
96
+
97
+ console.log('\nāœ… All basic tests passed! ScreenCaptureKit migration successful.');
98
+ });
99
+ });
100
+ });
101
+ });
102
+
103
+ } catch (error) {
104
+ console.error('āŒ Test failed:', error);
105
+ }
106
+ }
107
+
108
+ testScreenCaptureKit();
109
+ >>>>>>> screencapture
package/test-sync.js ADDED
@@ -0,0 +1,52 @@
1
+ const MacRecorder = require('./index');
2
+
3
+ console.log('šŸ”„ Testing ScreenCaptureKit Synchronous Operations...\n');
4
+
5
+ try {
6
+ const recorder = new MacRecorder();
7
+ console.log('āœ… Recorder created successfully');
8
+
9
+ // Test if we can access the native module methods directly
10
+ console.log('šŸ“‹ Available methods:');
11
+ const methods = Object.getOwnPropertyNames(recorder.__proto__);
12
+ methods.forEach(method => {
13
+ if (typeof recorder[method] === 'function') {
14
+ console.log(` • ${method}()`);
15
+ }
16
+ });
17
+
18
+ console.log('\nšŸŽÆ Testing basic functionality:');
19
+
20
+ // Test recording status (should be sync and work)
21
+ try {
22
+ const status = recorder.getStatus();
23
+ console.log(`āœ… getStatus(): ${JSON.stringify(status)}`);
24
+ } catch (err) {
25
+ console.log(`āŒ getStatus() failed: ${err.message}`);
26
+ }
27
+
28
+ // Test cursor position (should be sync and work)
29
+ try {
30
+ const cursor = recorder.getCurrentCursorPosition();
31
+ console.log(`āœ… getCurrentCursorPosition(): x=${cursor.x}, y=${cursor.y}, type=${cursor.cursorType}`);
32
+ } catch (err) {
33
+ console.log(`āŒ getCurrentCursorPosition() failed: ${err.message}`);
34
+ }
35
+
36
+ // Test cursor capture status (should be sync)
37
+ try {
38
+ const cursorStatus = recorder.getCursorCaptureStatus();
39
+ console.log(`āœ… getCursorCaptureStatus(): tracking=${cursorStatus.isTracking}`);
40
+ } catch (err) {
41
+ console.log(`āŒ getCursorCaptureStatus() failed: ${err.message}`);
42
+ }
43
+
44
+ console.log('\nšŸ“Š ScreenCaptureKit sync tests completed');
45
+ console.log('āš ļø Async functions (getDisplays, getWindows, getAudioDevices) may hang due to permission dialogs');
46
+ console.log('šŸ’” To fix: Grant screen recording permissions in System Preferences > Privacy & Security');
47
+
48
+ } catch (error) {
49
+ console.error('āŒ Critical error:', error);
50
+ }
51
+
52
+ process.exit(0);
@@ -0,0 +1,57 @@
1
+ const MacRecorder = require('./index');
2
+
3
+ function testWindowSelection() {
4
+ console.log('šŸ” Testing ScreenCaptureKit Window Selection...\n');
5
+
6
+ const recorder = new MacRecorder();
7
+
8
+ try {
9
+ // Test window enumeration
10
+ recorder.getWindows((err, windows) => {
11
+ if (err) {
12
+ console.error('āŒ getWindows failed:', err);
13
+ return;
14
+ }
15
+
16
+ console.log(`āœ… Found ${windows.length} windows`);
17
+
18
+ // Show first few windows with details
19
+ windows.slice(0, 5).forEach((window, index) => {
20
+ console.log(`${index + 1}. "${window.name}" - ${window.appName}`);
21
+ console.log(` ID: ${window.id}, Size: ${window.width}x${window.height}, Position: (${window.x}, ${window.y})`);
22
+ console.log(` On Screen: ${window.isOnScreen !== false ? 'Yes' : 'No'}\n`);
23
+ });
24
+
25
+ // Test window thumbnails if we have windows
26
+ if (windows.length > 0) {
27
+ const firstWindow = windows[0];
28
+ console.log(`šŸ“ø Testing window thumbnail for: "${firstWindow.name}"`);
29
+
30
+ recorder.getWindowThumbnail(firstWindow.id, 300, 200, (err, thumbnail) => {
31
+ if (err) {
32
+ console.error('āŒ getWindowThumbnail failed:', err);
33
+ } else {
34
+ console.log(`āœ… Window thumbnail generated: ${thumbnail.length} characters (base64)`);
35
+
36
+ // Test window recording info
37
+ console.log(`\nšŸŽ¬ Window recording info:`);
38
+ console.log(` Target Window: "${firstWindow.name}" (ID: ${firstWindow.id})`);
39
+ console.log(` App: ${firstWindow.appName}`);
40
+ console.log(` Capture Area: ${firstWindow.width}x${firstWindow.height}`);
41
+ console.log(` Would use windowId option for recording`);
42
+
43
+ console.log('\nāœ… Window selection tests completed successfully!');
44
+ }
45
+ });
46
+ } else {
47
+ console.log('āš ļø No windows found for thumbnail testing');
48
+ console.log('\nāœ… Window enumeration test completed successfully!');
49
+ }
50
+ });
51
+
52
+ } catch (error) {
53
+ console.error('āŒ Window selection test failed:', error);
54
+ }
55
+ }
56
+
57
+ testWindowSelection();