node-mac-recorder 2.4.11 → 2.4.13

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.
@@ -1,92 +0,0 @@
1
- const MacRecorder = require('./index');
2
-
3
- function testAPICompatibility() {
4
- console.log('šŸ”— Testing API Compatibility\n');
5
- console.log('Verifying that existing packages won\'t break...\n');
6
-
7
- const recorder = new MacRecorder();
8
- let compatibilityScore = 0;
9
- let totalTests = 0;
10
-
11
- function testAPI(apiName, expectedType, testFunction) {
12
- totalTests++;
13
- console.log(`Testing ${apiName}...`);
14
-
15
- try {
16
- const result = testFunction();
17
- if (typeof result === expectedType || result === true) {
18
- console.log(` āœ… ${apiName}: Compatible`);
19
- compatibilityScore++;
20
- return true;
21
- } else {
22
- console.log(` āŒ ${apiName}: Expected ${expectedType}, got ${typeof result}`);
23
- return false;
24
- }
25
- } catch (error) {
26
- console.log(` āš ļø ${apiName}: ${error.message}`);
27
- return false;
28
- }
29
- }
30
-
31
- console.log('šŸ“‹ Constructor and Basic Setup:');
32
- console.log('──────────────────────────────');
33
- testAPI('MacRecorder Constructor', 'object', () => new MacRecorder());
34
- testAPI('Method Existence Check', 'boolean', () => {
35
- const methods = ['getDisplays', 'getWindows', 'getAudioDevices', 'startRecording',
36
- 'stopRecording', 'checkPermissions', 'getCursorPosition'];
37
- return methods.every(method => typeof recorder[method] === 'function');
38
- });
39
-
40
- console.log('\nšŸ–±ļø Cursor Operations (Sync):');
41
- console.log('────────────────────────────');
42
- testAPI('getCurrentCursorPosition()', 'object', () => recorder.getCurrentCursorPosition());
43
- testAPI('getCursorCaptureStatus()', 'object', () => recorder.getCursorCaptureStatus());
44
-
45
- console.log('\nāš™ļø Configuration Methods:');
46
- console.log('─────────────────────────');
47
- testAPI('setOptions()', 'undefined', () => recorder.setOptions({}));
48
- testAPI('getModuleInfo()', 'object', () => recorder.getModuleInfo());
49
-
50
- console.log('\nšŸŽÆ Compatibility Test Results:');
51
- console.log('═'.repeat(50));
52
-
53
- const percentage = Math.round((compatibilityScore / totalTests) * 100);
54
- console.log(`āœ… Compatible APIs: ${compatibilityScore}/${totalTests}`);
55
- console.log(`šŸ“Š Compatibility Score: ${percentage}%`);
56
-
57
- if (percentage >= 90) {
58
- console.log('\nšŸŽ‰ EXCELLENT COMPATIBILITY!');
59
- console.log('✨ Existing packages should work without any changes');
60
- } else if (percentage >= 75) {
61
- console.log('\nšŸ‘ GOOD COMPATIBILITY');
62
- console.log('✨ Most existing packages should work with minimal adjustments');
63
- } else {
64
- console.log('\nāš ļø COMPATIBILITY ISSUES DETECTED');
65
- console.log('šŸ”§ Some existing packages may need updates');
66
- }
67
-
68
- console.log('\nšŸ“ API Test Summary:');
69
- console.log('─'.repeat(40));
70
- console.log('āœ… Constructor: Working');
71
- console.log('āœ… All expected methods: Present');
72
- console.log('āœ… Synchronous operations: Fully compatible');
73
- console.log('āš ļø Asynchronous operations: Need screen recording permissions');
74
-
75
- console.log('\nšŸš€ Migration Status:');
76
- console.log('─'.repeat(40));
77
- console.log('āœ… Native module: Built successfully for arm64');
78
- console.log('āœ… ScreenCaptureKit: Integrated and functional');
79
- console.log('āœ… Error handling: Improved (no more crashes)');
80
- console.log('āœ… API surface: 100% preserved');
81
- console.log('āš ļø Permission handling: Requires user setup');
82
-
83
- console.log('\nšŸ“‹ For Complete Functionality:');
84
- console.log('─'.repeat(40));
85
- console.log('1. Grant screen recording permissions in System Preferences');
86
- console.log('2. Ensure macOS 12.3+ on ARM64 (Apple Silicon)');
87
- console.log('3. Test with actual screen recording workflow');
88
-
89
- console.log(`\nšŸŽÆ Overall Migration Success: ${percentage >= 75 ? 'SUCCESSFUL' : 'NEEDS ATTENTION'} ✨`);
90
- }
91
-
92
- testAPICompatibility();
package/test-audio.js DELETED
@@ -1,94 +0,0 @@
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();
@@ -1,164 +0,0 @@
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();
@@ -1,119 +0,0 @@
1
- const ElectronWindowSelector = require('./electron-window-selector');
2
-
3
- // Electron environment simülasyonu
4
- console.log('🧪 Testing Electron Window Selector...\n');
5
-
6
- // Electron environment variable'ları set et
7
- process.env.ELECTRON_VERSION = '25.0.0';
8
-
9
- async function testElectronWindowSelector() {
10
- const selector = new ElectronWindowSelector();
11
-
12
- console.log(`šŸ” Environment: ${selector.isElectron ? 'Electron' : 'Node.js'}`);
13
-
14
- try {
15
- console.log('\n1ļøāƒ£ Testing Permission Check...');
16
- const permissions = await selector.checkPermissions();
17
- console.log('āœ… Permissions:', permissions);
18
-
19
- console.log('\n2ļøāƒ£ Testing Available Windows...');
20
- const windows = await selector.getAvailableWindows();
21
- console.log(`āœ… Found ${windows.length} windows`);
22
- if (windows.length > 0) {
23
- console.log(' šŸ“± Sample window:', {
24
- title: windows[0].title,
25
- appName: windows[0].appName,
26
- size: `${windows[0].width}x${windows[0].height}`
27
- });
28
- }
29
-
30
- console.log('\n3ļøāƒ£ Testing Available Displays...');
31
- const displays = await selector.getAvailableDisplays();
32
- console.log(`āœ… Found ${displays.length} displays`);
33
- if (displays.length > 0) {
34
- console.log(' šŸ–„ļø Primary display:', {
35
- name: displays[0].name,
36
- resolution: `${displays[0].width}x${displays[0].height}`,
37
- isPrimary: displays[0].isPrimary
38
- });
39
- }
40
-
41
- console.log('\n4ļøāƒ£ Testing Window Selection (Electron Safe Mode)...');
42
- const windowSelectionPromise = selector.selectWindow();
43
-
44
- // Event listeners
45
- selector.on('windowSelected', (windowInfo) => {
46
- console.log('šŸŽÆ Window selected event:', {
47
- title: windowInfo.title,
48
- appName: windowInfo.appName,
49
- position: `${windowInfo.x},${windowInfo.y}`,
50
- size: `${windowInfo.width}x${windowInfo.height}`
51
- });
52
- });
53
-
54
- selector.on('selectionStarted', () => {
55
- console.log('🟢 Window selection started');
56
- });
57
-
58
- const selectedWindow = await windowSelectionPromise;
59
- console.log('āœ… Window selection completed');
60
-
61
- console.log('\n5ļøāƒ£ Testing Screen Selection (Electron Safe Mode)...');
62
- const screenSelectionPromise = selector.selectScreen();
63
-
64
- selector.on('screenSelected', (screenInfo) => {
65
- console.log('šŸ–„ļø Screen selected event:', {
66
- name: screenInfo.name || 'Display ' + screenInfo.id,
67
- resolution: `${screenInfo.width}x${screenInfo.height}`,
68
- isPrimary: screenInfo.isPrimary
69
- });
70
- });
71
-
72
- const selectedScreen = await screenSelectionPromise;
73
- console.log('āœ… Screen selection completed');
74
-
75
- console.log('\n6ļøāƒ£ Testing Recording Preview (Electron Safe Mode)...');
76
- if (selectedWindow) {
77
- await selector.showRecordingPreview(selectedWindow);
78
- console.log('āœ… Recording preview shown (Electron mode - no native overlay)');
79
-
80
- await selector.hideRecordingPreview();
81
- console.log('āœ… Recording preview hidden');
82
- }
83
-
84
- console.log('\n7ļøāƒ£ Testing Screen Recording Preview (Electron Safe Mode)...');
85
- if (selectedScreen) {
86
- await selector.showScreenRecordingPreview(selectedScreen);
87
- console.log('āœ… Screen recording preview shown (Electron mode - no native overlay)');
88
-
89
- await selector.hideScreenRecordingPreview();
90
- console.log('āœ… Screen recording preview hidden');
91
- }
92
-
93
- console.log('\n8ļøāƒ£ Cleanup...');
94
- await selector.cleanup();
95
- console.log('āœ… Cleanup completed');
96
-
97
- console.log('\nšŸŽ‰ All Electron Window Selector tests PASSED!');
98
-
99
- } catch (error) {
100
- console.error('\nāŒ Test failed:', error.message);
101
- console.error(' Stack:', error.stack);
102
-
103
- // Cleanup on error
104
- try {
105
- await selector.cleanup();
106
- } catch (cleanupError) {
107
- console.error('āŒ Cleanup failed:', cleanupError.message);
108
- }
109
- }
110
- }
111
-
112
- // Run test
113
- testElectronWindowSelector().then(() => {
114
- console.log('\nāœ… Test completed');
115
- process.exit(0);
116
- }).catch((error) => {
117
- console.error('\nāŒ Test suite failed:', error);
118
- process.exit(1);
119
- });
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const ElectronWindowSelector = require('./electron-window-selector.js');
4
-
5
- console.log('🧪 Testing Fixed Overlay Functionality');
6
- console.log('=====================================');
7
-
8
- async function testOverlayFunctionality() {
9
- const selector = new ElectronWindowSelector();
10
-
11
- try {
12
- console.log('\nšŸ” Environment Check:');
13
- const status = selector.getStatus();
14
- console.log(` - Electron Mode: ${status.isElectron}`);
15
-
16
- console.log('\n🪟 Testing Window Detection...');
17
-
18
- // Test real-time window detection
19
- console.log('Move your mouse over different windows...');
20
- console.log('Press Ctrl+C to stop\n');
21
-
22
- let lastWindowId = null;
23
-
24
- const checkInterval = setInterval(async () => {
25
- try {
26
- // Simulate what Electron app would do - poll for current window
27
- const windowStatus = require('./build/Release/mac_recorder.node').getWindowSelectionStatus();
28
-
29
- if (windowStatus && windowStatus.currentWindow) {
30
- const window = windowStatus.currentWindow;
31
-
32
- if (window.id !== lastWindowId) {
33
- lastWindowId = window.id;
34
-
35
- console.log(`šŸŽÆ Window Detected: ${window.appName} - "${window.title}"`);
36
- console.log(` šŸ“ Position: (${window.x}, ${window.y})`);
37
- console.log(` šŸ“ Size: ${window.width}x${window.height}`);
38
-
39
- if (window.screenId !== undefined) {
40
- console.log(` šŸ–„ļø Screen: ${window.screenId} (${window.screenWidth}x${window.screenHeight})`);
41
- }
42
- console.log('');
43
- }
44
- } else if (lastWindowId !== null) {
45
- lastWindowId = null;
46
- console.log('🚪 No window under cursor\n');
47
- }
48
- } catch (error) {
49
- console.error('Error during window detection:', error.message);
50
- }
51
- }, 100); // Check every 100ms for smooth tracking
52
-
53
- // Handle Ctrl+C gracefully
54
- process.on('SIGINT', () => {
55
- console.log('\n\nšŸ›‘ Stopping test...');
56
- clearInterval(checkInterval);
57
- selector.cleanup().then(() => {
58
- console.log('āœ… Cleanup completed');
59
- process.exit(0);
60
- });
61
- });
62
-
63
- } catch (error) {
64
- console.error('āŒ Test failed:', error.message);
65
- process.exit(1);
66
- }
67
- }
68
-
69
- // Set Electron environment for testing
70
- process.env.ELECTRON_VERSION = '25.0.0';
71
-
72
- testOverlayFunctionality();
package/test-recording.js DELETED
@@ -1,142 +0,0 @@
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();