node-mac-recorder 2.16.10 โ†’ 2.16.12

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.
Files changed (41) hide show
  1. package/.claude/settings.local.json +1 -1
  2. package/CLAUDE.md +51 -3
  3. package/package.json +1 -1
  4. package/src/avfoundation_recorder.mm +85 -55
  5. package/src/mac_recorder.mm +49 -57
  6. package/bring-to-front-test.js +0 -159
  7. package/capture-test.js +0 -87
  8. package/cursor-test.js +0 -22
  9. package/debug-test.js +0 -95
  10. package/default-auto-front-test.js +0 -86
  11. package/final-multi-display-test.js +0 -74
  12. package/list-test.js +0 -46
  13. package/quick-cursor-test.js +0 -20
  14. package/quick-screen-test.js +0 -34
  15. package/quick-test.js +0 -35
  16. package/system-sound-test.js +0 -46
  17. package/test-audio-controls.js +0 -104
  18. package/test-both.js +0 -46
  19. package/test-console-logs.js +0 -81
  20. package/test-coordinate-debug.js +0 -25
  21. package/test-cursor-visible.js +0 -41
  22. package/test-electron-detection.js +0 -44
  23. package/test-final-coordinate-fix.js +0 -38
  24. package/test-hybrid.js +0 -53
  25. package/test-macos14-forced.js +0 -107
  26. package/test-macos14.js +0 -56
  27. package/test-multi-display-overlay.js +0 -185
  28. package/test-multi-screen-selection.js +0 -171
  29. package/test-multidisplay-fix.js +0 -120
  30. package/test-native-cursor.js +0 -31
  31. package/test-overlay-tracking.js +0 -175
  32. package/test-primary-live.js +0 -17
  33. package/test-primary-window-debug.js +0 -33
  34. package/test-quick.js +0 -55
  35. package/test-real-screen-ids.js +0 -32
  36. package/test-screencapture-only.js +0 -50
  37. package/test-screencapture-pure.js +0 -69
  38. package/test-screencapture.js +0 -52
  39. package/test-system-audio.js +0 -104
  40. package/test-window-selector-fix.js +0 -88
  41. package/window-selector-test.js +0 -160
@@ -1,17 +0,0 @@
1
- const MacRecorder = require('./index');
2
- const WindowSelector = MacRecorder.WindowSelector;
3
-
4
- console.log('๐Ÿ”ฅ LIVE Primary Display Test - Move cursor NOW!');
5
- console.log(' - Quickly move to primary display windows');
6
- console.log(' - Look for [PRIMARY] tags in logs');
7
-
8
- const selector = new WindowSelector();
9
-
10
- selector.startSelection().then(() => {
11
- // Auto-stop after 8 seconds
12
- setTimeout(() => {
13
- selector.stopSelection().then(() => {
14
- process.exit(0);
15
- });
16
- }, 8000);
17
- });
@@ -1,33 +0,0 @@
1
- const MacRecorder = require('./index');
2
- const WindowSelector = MacRecorder.WindowSelector;
3
-
4
- async function testPrimaryWindowDebug() {
5
- console.log('๐Ÿ” Testing PRIMARY display window debugging...');
6
-
7
- const recorder = new MacRecorder();
8
- const displays = await recorder.getDisplays();
9
-
10
- const primary = displays.find(d => d.isPrimary);
11
- console.log(`Primary display: ${primary.name} at (${primary.x}, ${primary.y}) ${primary.width}x${primary.height}`);
12
-
13
- const selector = new WindowSelector();
14
-
15
- try {
16
- console.log('๐Ÿš€ Starting window selection...');
17
- console.log('๐Ÿ“ IMPORTANT: Move cursor to a window ON THE PRIMARY DISPLAY');
18
- console.log(' - Look for windows at coordinates like (0, 50) or (100, 100)');
19
- console.log(' - Should see GlobalOffset: (3440, 56) for primary display');
20
-
21
- await selector.startSelection();
22
-
23
- // Let it run for 15 seconds to catch primary display windows
24
- await new Promise(resolve => setTimeout(resolve, 15000));
25
-
26
- await selector.stopSelection();
27
-
28
- } catch (error) {
29
- console.log(`โŒ Test failed: ${error.message}`);
30
- }
31
- }
32
-
33
- testPrimaryWindowDebug();
package/test-quick.js DELETED
@@ -1,55 +0,0 @@
1
- const MacRecorder = require('./index');
2
-
3
- // Test video creation in Node.js
4
- // process.env.ELECTRON_RUN_AS_NODE = '1';
5
-
6
- console.log('๐ŸŽฏ Quick ScreenCaptureKit Test');
7
-
8
- async function quickTest() {
9
- const recorder = new MacRecorder();
10
-
11
- try {
12
- const outputPath = './test-output/quick-test.mov';
13
-
14
- console.log('๐Ÿ“น Starting recording...');
15
- const result = await recorder.startRecording(outputPath, {
16
- captureCursor: true,
17
- includeMicrophone: false,
18
- includeSystemAudio: false
19
- });
20
-
21
- if (result) {
22
- console.log('โœ… Recording started successfully');
23
-
24
- // Record for only 3 seconds
25
- console.log('โฑ๏ธ Recording for 3 seconds...');
26
- await new Promise(resolve => setTimeout(resolve, 3000));
27
-
28
- console.log('๐Ÿ›‘ Stopping recording...');
29
- await recorder.stopRecording();
30
-
31
- // Check if file exists and has content
32
- const fs = require('fs');
33
- setTimeout(() => {
34
- if (fs.existsSync(outputPath)) {
35
- const stats = fs.statSync(outputPath);
36
- console.log(`โœ… Video file: ${outputPath} (${stats.size} bytes)`);
37
-
38
- if (stats.size > 1000) {
39
- console.log('๐ŸŽ‰ SUCCESS! ScreenCaptureKit is working!');
40
- } else {
41
- console.log('โš ๏ธ File too small');
42
- }
43
- } else {
44
- console.log('โŒ No output file');
45
- }
46
- }, 2000);
47
- } else {
48
- console.log('โŒ Failed to start recording');
49
- }
50
- } catch (error) {
51
- console.log('โŒ Error:', error.message);
52
- }
53
- }
54
-
55
- quickTest().catch(console.error);
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const WindowSelector = require('./window-selector');
4
-
5
- async function testRealScreenIDs() {
6
- console.log('Testing real screen ID generation...\n');
7
-
8
- const selector = new WindowSelector();
9
-
10
- // Start screen selection to generate screen info
11
- console.log('Starting screen selection (will timeout in 3 seconds)...');
12
-
13
- const startPromise = selector.startScreenSelection();
14
-
15
- // Wait a bit for screen info to be generated
16
- await new Promise(resolve => setTimeout(resolve, 1000));
17
-
18
- // Try to get selected screen info (should be null since nothing selected)
19
- const selectedInfo = selector.getSelectedScreen();
20
- console.log('Selected screen info (should be null):', selectedInfo);
21
-
22
- // Clean up
23
- try {
24
- await selector.stopScreenSelection();
25
- } catch (e) {
26
- // Ignore
27
- }
28
-
29
- console.log('\nTest completed. Check logs above for screen creation details.');
30
- }
31
-
32
- testRealScreenIDs().catch(console.error);
@@ -1,50 +0,0 @@
1
- const MacRecorder = require('./index');
2
-
3
- console.log('๐ŸŽฏ Testing PURE ScreenCaptureKit (No AVFoundation)');
4
-
5
- async function testScreenCaptureKitOnly() {
6
- const recorder = new MacRecorder();
7
-
8
- try {
9
- const outputPath = './test-output/screencapturekit-only-test.mov';
10
-
11
- console.log('๐Ÿ“น Starting ScreenCaptureKit-only recording...');
12
- const success = await recorder.startRecording(outputPath, {
13
- captureCursor: true,
14
- includeMicrophone: false,
15
- includeSystemAudio: false
16
- });
17
-
18
- if (success) {
19
- console.log('โœ… Recording started successfully');
20
-
21
- // Record for 5 seconds
22
- console.log('โฑ๏ธ Recording for 5 seconds...');
23
- await new Promise(resolve => setTimeout(resolve, 5000));
24
-
25
- console.log('๐Ÿ›‘ Stopping recording...');
26
- await recorder.stopRecording();
27
-
28
- // Check if file exists and has content
29
- const fs = require('fs');
30
- if (fs.existsSync(outputPath)) {
31
- const stats = fs.statSync(outputPath);
32
- console.log(`โœ… Video file created: ${outputPath} (${stats.size} bytes)`);
33
-
34
- if (stats.size > 1000) {
35
- console.log('โœ… ScreenCaptureKit-only recording successful');
36
- } else {
37
- console.log('โš ๏ธ File size is very small');
38
- }
39
- } else {
40
- console.log('โŒ Video file not found');
41
- }
42
- } else {
43
- console.log('โŒ Failed to start recording');
44
- }
45
- } catch (error) {
46
- console.log('โŒ Error during test:', error.message);
47
- }
48
- }
49
-
50
- testScreenCaptureKitOnly().catch(console.error);
@@ -1,69 +0,0 @@
1
- const MacRecorder = require('./index');
2
-
3
- // Simulate Electron environment
4
- process.env.ELECTRON_RUN_AS_NODE = '1';
5
-
6
- console.log('๐ŸŽฏ Testing PURE ScreenCaptureKit (Ultra-Safe for Electron)');
7
-
8
- async function testPureScreenCaptureKit() {
9
- const recorder = new MacRecorder();
10
-
11
- try {
12
- const outputPath = './test-output/screencapturekit-pure-test.mov';
13
-
14
- console.log('๐Ÿ“น Starting PURE ScreenCaptureKit recording...');
15
- const result = await recorder.startRecording(outputPath, {
16
- captureCursor: true,
17
- includeMicrophone: false,
18
- includeSystemAudio: false
19
- });
20
-
21
- if (result) {
22
- console.log('โœ… Recording started successfully');
23
-
24
- // Record for 10 seconds to get more frames
25
- console.log('โฑ๏ธ Recording for 10 seconds...');
26
- await new Promise(resolve => setTimeout(resolve, 10000));
27
-
28
- console.log('๐Ÿ›‘ Stopping recording...');
29
- await recorder.stopRecording();
30
-
31
- // Check if file exists and has content
32
- const fs = require('fs');
33
- if (fs.existsSync(outputPath)) {
34
- const stats = fs.statSync(outputPath);
35
- console.log(`โœ… Video file created: ${outputPath} (${stats.size} bytes)`);
36
-
37
- if (stats.size > 10000) {
38
- console.log('โœ… PURE ScreenCaptureKit successful - Real video!');
39
-
40
- // Try to get more info about the video
41
- setTimeout(() => {
42
- const { spawn } = require('child_process');
43
- const ffprobe = spawn('ffprobe', ['-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', outputPath]);
44
- let output = '';
45
- ffprobe.stdout.on('data', (data) => output += data);
46
- ffprobe.on('close', () => {
47
- try {
48
- const info = JSON.parse(output);
49
- console.log(`๐ŸŽž๏ธ Video info: ${info.format.duration}s, ${info.streams[0].nb_frames} frames`);
50
- } catch (e) {
51
- console.log('๐Ÿ“Š Video analysis failed, but file exists');
52
- }
53
- });
54
- }, 1000);
55
- } else {
56
- console.log('โš ๏ธ File size is very small - may not have content');
57
- }
58
- } else {
59
- console.log('โŒ Video file not found');
60
- }
61
- } else {
62
- console.log('โŒ Failed to start recording');
63
- }
64
- } catch (error) {
65
- console.log('โŒ Error during test:', error.message);
66
- }
67
- }
68
-
69
- testPureScreenCaptureKit().catch(console.error);
@@ -1,52 +0,0 @@
1
- const MacRecorder = require('./index');
2
- const fs = require('fs');
3
-
4
- async function testScreenCaptureKit() {
5
- const recorder = new MacRecorder();
6
-
7
- console.log('๐Ÿ” Testing ScreenCaptureKit Integration');
8
-
9
- try {
10
- // Check if we can start recording
11
- const outputPath = './test-output/screencapturekit-test.mov';
12
-
13
- console.log('๐Ÿ“น Starting recording with ScreenCaptureKit...');
14
- const success = await recorder.startRecording(outputPath, {
15
- captureCursor: true,
16
- includeMicrophone: false,
17
- includeSystemAudio: false
18
- });
19
-
20
- if (success) {
21
- console.log('โœ… Recording started successfully');
22
-
23
- // Record for 5 seconds
24
- console.log('โฑ๏ธ Recording for 5 seconds...');
25
- await new Promise(resolve => setTimeout(resolve, 5000));
26
-
27
- console.log('๐Ÿ›‘ Stopping recording...');
28
- await recorder.stopRecording();
29
-
30
- // Check if file exists and has content
31
- if (fs.existsSync(outputPath)) {
32
- const stats = fs.statSync(outputPath);
33
- console.log(`โœ… Video file created: ${outputPath} (${stats.size} bytes)`);
34
-
35
- if (stats.size > 1000) {
36
- console.log('โœ… File size looks good - recording likely successful');
37
- } else {
38
- console.log('โš ๏ธ File size is very small - recording may have failed');
39
- }
40
- } else {
41
- console.log('โŒ Video file not found');
42
- }
43
- } else {
44
- console.log('โŒ Failed to start recording');
45
- }
46
- } catch (error) {
47
- console.log('โŒ Error during test:', error.message);
48
- }
49
- }
50
-
51
- // Run test
52
- testScreenCaptureKit().catch(console.error);
@@ -1,104 +0,0 @@
1
- const MacRecorder = require('./index');
2
- const path = require('path');
3
-
4
- async function testSystemAudio() {
5
- const recorder = new MacRecorder();
6
-
7
- console.log('๐ŸŽต Sistem Sesi Yakalama Testi BaลŸlฤฑyor...\n');
8
-
9
- try {
10
- // ร–nce izinleri kontrol et
11
- const permissions = await recorder.checkPermissions();
12
- console.log('๐Ÿ“‹ ฤฐzinler:', permissions);
13
-
14
- if (!permissions.screenRecording) {
15
- console.log('โŒ Ekran kayฤฑt izni gerekli. System Preferences > Security & Privacy > Screen Recording');
16
- return;
17
- }
18
-
19
- // Mevcut ses cihazlarฤฑnฤฑ listele
20
- console.log('\n๐ŸŽค Mevcut Ses Cihazlarฤฑ:');
21
- const audioDevices = await recorder.getAudioDevices();
22
- audioDevices.forEach((device, index) => {
23
- console.log(`${index + 1}. ${device.name}`);
24
- if (device.id) console.log(` ID: ${device.id}`);
25
- });
26
-
27
- // Sistem sesi cihazฤฑ ara
28
- const systemAudioDevice = audioDevices.find(device =>
29
- device.name.toLowerCase().includes('blackhole') ||
30
- device.name.toLowerCase().includes('soundflower') ||
31
- device.name.toLowerCase().includes('loopback') ||
32
- device.name.toLowerCase().includes('aggregate') ||
33
- device.name.toLowerCase().includes('imobie')
34
- );
35
-
36
- console.log('\n=== Test 1: Sistem Sesi KAPALI ===');
37
- const outputPath1 = path.join(__dirname, 'test-output', 'no-system-audio.mov');
38
-
39
- await recorder.startRecording(outputPath1, {
40
- includeSystemAudio: false, // Sistem sesi kapalฤฑ
41
- includeMicrophone: false,
42
- captureCursor: true,
43
- captureArea: { x: 0, y: 0, width: 400, height: 300 } // Kรผรงรผk alan
44
- });
45
-
46
- console.log('๐Ÿ”ด 5 saniye kayฤฑt yapฤฑlฤฑyor (sistem sesi KAPALI)...');
47
- console.log('๐Ÿ’ก ลžimdi mรผzik รงal veya YouTube video aรง - ses KAYIT EDฤฐLMEMELฤฐ');
48
-
49
- await new Promise(resolve => setTimeout(resolve, 5000));
50
- await recorder.stopRecording();
51
- console.log(`โœ… Kayฤฑt tamamlandฤฑ: ${outputPath1}`);
52
-
53
- // 2 saniye bekle
54
- await new Promise(resolve => setTimeout(resolve, 2000));
55
-
56
- console.log('\n=== Test 2: Sistem Sesi Aร‡IK ===');
57
- const outputPath2 = path.join(__dirname, 'test-output', 'with-system-audio.mov');
58
-
59
- const options2 = {
60
- includeSystemAudio: true, // Sistem sesi aรงฤฑk
61
- includeMicrophone: false,
62
- captureCursor: true,
63
- captureArea: { x: 0, y: 0, width: 400, height: 300 }
64
- };
65
-
66
- // EฤŸer sistem sesi cihazฤฑ varsa onu kullan
67
- if (systemAudioDevice) {
68
- options2.systemAudioDeviceId = systemAudioDevice.id;
69
- console.log(`๐ŸŽฏ Kullanฤฑlan sistem sesi cihazฤฑ: ${systemAudioDevice.name}`);
70
- }
71
-
72
- await recorder.startRecording(outputPath2, options2);
73
-
74
- console.log('๐Ÿ”ด 5 saniye kayฤฑt yapฤฑlฤฑyor (sistem sesi Aร‡IK)...');
75
- console.log('๐ŸŽต ลžimdi mรผzik รงal veya YouTube video aรง - ses KAYIT EDฤฐLMELฤฐ');
76
-
77
- await new Promise(resolve => setTimeout(resolve, 5000));
78
- await recorder.stopRecording();
79
- console.log(`โœ… Kayฤฑt tamamlandฤฑ: ${outputPath2}`);
80
-
81
- console.log('\n=== ๐ŸŽ‰ TEST TAMAMLANDI ===');
82
- console.log('๐Ÿ“ Kayฤฑtlarฤฑ karลŸฤฑlaลŸtฤฑr:');
83
- console.log(`1. ${outputPath1} (sistem sesi YOK)`);
84
- console.log(`2. ${outputPath2} (sistem sesi VAR)`);
85
-
86
- if (!systemAudioDevice) {
87
- console.log('\nโš ๏ธ Sistem sesi cihazฤฑ bulunamadฤฑ!');
88
- console.log('๐Ÿ’ก Daha iyi sistem sesi yakalama iรงin ลŸunlarฤฑ yรผkle:');
89
- console.log(' โ€ข BlackHole: https://github.com/ExistentialAudio/BlackHole');
90
- console.log(' โ€ข Soundflower: https://github.com/mattingalls/Soundflower');
91
- }
92
-
93
- console.log('\n๐Ÿ” Kayฤฑtlarฤฑ test etmek iรงin:');
94
- console.log('1. Dosyalarฤฑ QuickTime Player ile aรง');
95
- console.log('2. ฤฐlk kayฤฑtta ses olmamalฤฑ');
96
- console.log('3. ฤฐkinci kayฤฑtta sistem sesi olmalฤฑ');
97
-
98
- } catch (error) {
99
- console.error('โŒ Test hatasฤฑ:', error.message);
100
- }
101
- }
102
-
103
- // Testi รงalฤฑลŸtฤฑr
104
- testSystemAudio();
@@ -1,88 +0,0 @@
1
- const MacRecorder = require('./index');
2
- const WindowSelector = MacRecorder.WindowSelector;
3
-
4
- async function testWindowSelector() {
5
- console.log('๐ŸชŸ Testing FIXED window selector multi-display...');
6
-
7
- const recorder = new MacRecorder();
8
- const displays = await recorder.getDisplays();
9
-
10
- console.log('๐Ÿ“Š Display setup:');
11
- displays.forEach((display, index) => {
12
- console.log(` ${display.name}: ${display.resolution} at (${display.x}, ${display.y}) ${display.isPrimary ? '[PRIMARY]' : ''}`);
13
- });
14
-
15
- const selector = new WindowSelector();
16
-
17
- try {
18
- console.log('\n๐Ÿ” Starting window selection...');
19
- console.log(' - Test windows on BOTH displays');
20
- console.log(' - Check if buttons appear correctly positioned');
21
- console.log(' - Primary display should now work correctly');
22
-
23
- await selector.startSelection();
24
-
25
- // Let it run for 20 seconds for thorough testing
26
- await new Promise(resolve => setTimeout(resolve, 20000));
27
-
28
- console.log('๐Ÿ›‘ Stopping window selection...');
29
- await selector.stopSelection();
30
-
31
- console.log('โœ… Window selector test completed!');
32
-
33
- } catch (error) {
34
- console.log(`โŒ Window selector test failed: ${error.message}`);
35
- console.log(error.stack);
36
- }
37
- }
38
-
39
- async function testSecondaryDisplayRecording() {
40
- console.log('\n๐ŸŽฅ Testing secondary display recording...');
41
-
42
- const recorder = new MacRecorder();
43
- const displays = await recorder.getDisplays();
44
-
45
- const secondaryDisplay = displays.find(d => !d.isPrimary);
46
- if (!secondaryDisplay) {
47
- console.log('โš ๏ธ No secondary display found');
48
- return;
49
- }
50
-
51
- console.log(`๐Ÿ–ฅ๏ธ Testing recording on ${secondaryDisplay.name} (ID: ${secondaryDisplay.id})`);
52
-
53
- try {
54
- const outputPath = `./test-output/secondary-display-fix-test.mov`;
55
-
56
- await recorder.startRecording(outputPath, {
57
- displayId: secondaryDisplay.id,
58
- captureCursor: true,
59
- includeMicrophone: false,
60
- includeSystemAudio: false
61
- });
62
-
63
- console.log('โœ… Recording started on secondary display');
64
-
65
- // Record for 3 seconds
66
- await new Promise(resolve => setTimeout(resolve, 3000));
67
-
68
- await recorder.stopRecording();
69
- console.log('โœ… Recording completed on secondary display');
70
-
71
- } catch (error) {
72
- console.log(`โŒ Secondary display recording failed: ${error.message}`);
73
- }
74
- }
75
-
76
- async function runTests() {
77
- try {
78
- await testWindowSelector();
79
- await testSecondaryDisplayRecording();
80
-
81
- console.log('\n๐ŸŽ‰ All tests completed!');
82
-
83
- } catch (error) {
84
- console.log(`โŒ Test suite failed: ${error.message}`);
85
- }
86
- }
87
-
88
- runTests();
@@ -1,160 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const WindowSelector = require('./window-selector');
4
- const readline = require('readline');
5
-
6
- async function main() {
7
- console.log('๐Ÿ” Window Selector Test');
8
- console.log('=======================\n');
9
-
10
- const selector = new WindowSelector();
11
-
12
- try {
13
- // Permissions kontrolรผ
14
- console.log('1๏ธโƒฃ Checking permissions...');
15
- const permissions = await selector.checkPermissions();
16
- console.log('Permissions:', permissions);
17
-
18
- if (!permissions.screenRecording || !permissions.accessibility) {
19
- console.warn('โš ๏ธ Warning: Some permissions missing. Go to System Preferences > Security & Privacy');
20
- console.warn(' - Privacy > Screen Recording: Enable for Terminal/Node');
21
- console.warn(' - Privacy > Accessibility: Enable for Terminal/Node');
22
- console.log();
23
- }
24
-
25
- // Event listener'larฤฑ ayarla
26
- selector.on('selectionStarted', () => {
27
- console.log('โœ… Window selection started');
28
- console.log('๐Ÿ–ฑ๏ธ Move your cursor over windows to highlight them');
29
- console.log('๐ŸŽฏ Click "Select Window" button to choose a window');
30
- console.log('โŒ Press Ctrl+C to cancel\n');
31
- });
32
-
33
- selector.on('windowEntered', (window) => {
34
- console.log(`๐Ÿ  Entered window: "${window.title}" - ${window.appName}`);
35
- });
36
-
37
- selector.on('windowLeft', (window) => {
38
- console.log(`๐Ÿšช Left window: "${window.title}" - ${window.appName}`);
39
- });
40
-
41
- selector.on('windowSelected', (windowInfo) => {
42
- console.log('\n๐ŸŽ‰ Window Selected!');
43
- console.log('==================');
44
- console.log(`Title: "${windowInfo.title}"`);
45
- console.log(`Application: ${windowInfo.appName}`);
46
- console.log(`Position: (${windowInfo.x}, ${windowInfo.y})`);
47
- console.log(`Size: ${windowInfo.width} x ${windowInfo.height}`);
48
- console.log(`Screen ID: ${windowInfo.screenId}`);
49
- console.log(`Screen Position: (${windowInfo.screenX}, ${windowInfo.screenY})`);
50
- console.log(`Screen Size: ${windowInfo.screenWidth} x ${windowInfo.screenHeight}`);
51
- });
52
-
53
- selector.on('selectionStopped', () => {
54
- console.log('๐Ÿ›‘ Window selection stopped');
55
- });
56
-
57
- selector.on('error', (error) => {
58
- console.error('โŒ Error:', error.message);
59
- });
60
-
61
- // Ctrl+C handler
62
- process.on('SIGINT', async () => {
63
- console.log('\n\n๐Ÿ›‘ Stopping window selection...');
64
- await selector.cleanup();
65
- process.exit(0);
66
- });
67
-
68
- console.log('2๏ธโƒฃ Testing window selection...\n');
69
-
70
- // Seรงim baลŸlat
71
- const selectedWindow = await selector.selectWindow();
72
-
73
- if (selectedWindow) {
74
- console.log('\nโœจ Final result:');
75
- console.log(JSON.stringify(selectedWindow, null, 2));
76
-
77
- // Ek bilgiler
78
- console.log('\n๐Ÿ“Š Additional Analysis:');
79
- console.log(`Window area: ${selectedWindow.width * selectedWindow.height} pixels`);
80
- console.log(`Aspect ratio: ${(selectedWindow.width / selectedWindow.height).toFixed(2)}`);
81
-
82
- // Window bounds relative to screen
83
- const relativeX = selectedWindow.x - selectedWindow.screenX;
84
- const relativeY = selectedWindow.y - selectedWindow.screenY;
85
- console.log(`Relative position on screen: (${relativeX}, ${relativeY})`);
86
-
87
- if (relativeX < 0 || relativeY < 0 ||
88
- relativeX + selectedWindow.width > selectedWindow.screenWidth ||
89
- relativeY + selectedWindow.height > selectedWindow.screenHeight) {
90
- console.log('โš ๏ธ Window extends beyond screen boundaries (multi-monitor setup)');
91
- } else {
92
- console.log('โœ… Window is fully contained within its screen');
93
- }
94
- }
95
-
96
- } catch (error) {
97
- console.error('โŒ Test failed:', error.message);
98
- console.error(error.stack);
99
- } finally {
100
- await selector.cleanup();
101
- console.log('\n๐Ÿงน Cleanup completed');
102
- process.exit(0);
103
- }
104
- }
105
-
106
- // Alternative test function for programmatic testing
107
- async function testWindowSelectorAPI() {
108
- console.log('๐Ÿงช API Test Mode');
109
- console.log('===============\n');
110
-
111
- const selector = new WindowSelector();
112
-
113
- try {
114
- // Test 1: Status before selection
115
- console.log('Test 1: Initial status');
116
- const initialStatus = selector.getStatus();
117
- console.log('Initial status:', initialStatus);
118
- console.assert(!initialStatus.isSelecting, 'Should not be selecting initially');
119
- console.assert(!initialStatus.hasSelectedWindow, 'Should not have selected window initially');
120
- console.log('โœ… Initial status test passed\n');
121
-
122
- // Test 2: Start selection
123
- console.log('Test 2: Start selection');
124
- await selector.startSelection();
125
- const selectingStatus = selector.getStatus();
126
- console.log('Selecting status:', selectingStatus);
127
- console.assert(selectingStatus.isSelecting, 'Should be selecting after start');
128
- console.log('โœ… Start selection test passed\n');
129
-
130
- // Wait a bit to let user move cursor
131
- console.log('Move your cursor over different windows for 3 seconds...');
132
- await new Promise(resolve => setTimeout(resolve, 3000));
133
-
134
- // Test 3: Stop selection
135
- console.log('Test 3: Stop selection');
136
- await selector.stopSelection();
137
- const stoppedStatus = selector.getStatus();
138
- console.log('Stopped status:', stoppedStatus);
139
- console.assert(!stoppedStatus.isSelecting, 'Should not be selecting after stop');
140
- console.log('โœ… Stop selection test passed\n');
141
-
142
- console.log('๐ŸŽ‰ All API tests passed!');
143
-
144
- } catch (error) {
145
- console.error('โŒ API test failed:', error.message);
146
- throw error;
147
- } finally {
148
- await selector.cleanup();
149
- }
150
- }
151
-
152
- // Parse command line arguments
153
- const args = process.argv.slice(2);
154
- const testMode = args.includes('--api-test') ? 'api' : 'interactive';
155
-
156
- if (testMode === 'api') {
157
- testWindowSelectorAPI().catch(console.error);
158
- } else {
159
- main().catch(console.error);
160
- }