node-mac-recorder 2.10.15 → 2.10.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.10.15",
3
+ "version": "2.10.16",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Test script to analyze overlay tracking issues during window movement
5
+ */
6
+
7
+ const WindowSelector = require('./window-selector');
8
+
9
+ async function testOverlayTracking() {
10
+ console.log('šŸ”¬ OVERLAY TRACKING ANALYSIS');
11
+ console.log('=============================\n');
12
+
13
+ const selector = new WindowSelector();
14
+
15
+ try {
16
+ // Track mouse vs overlay position data
17
+ let mousePositions = [];
18
+ let overlayUpdates = [];
19
+ let windowMovements = [];
20
+
21
+ selector.on('windowEntered', (window) => {
22
+ const timestamp = Date.now();
23
+ overlayUpdates.push({
24
+ timestamp,
25
+ type: 'entered',
26
+ window: {
27
+ id: window.id,
28
+ title: window.title,
29
+ appName: window.appName,
30
+ x: window.x,
31
+ y: window.y,
32
+ width: window.width,
33
+ height: window.height
34
+ }
35
+ });
36
+
37
+ console.log(`šŸ  [${new Date(timestamp).toISOString().substr(11,12)}] ENTERED: "${window.title}" at (${window.x}, ${window.y}) ${window.width}Ɨ${window.height}`);
38
+ });
39
+
40
+ selector.on('windowLeft', (window) => {
41
+ const timestamp = Date.now();
42
+ overlayUpdates.push({
43
+ timestamp,
44
+ type: 'left',
45
+ window: {
46
+ id: window.id,
47
+ title: window.title,
48
+ x: window.x,
49
+ y: window.y
50
+ }
51
+ });
52
+
53
+ console.log(`🚪 [${new Date(timestamp).toISOString().substr(11,12)}] LEFT: "${window.title}" from (${window.x}, ${window.y})`);
54
+ });
55
+
56
+ console.log('šŸŽÆ Starting window selection...');
57
+ console.log('šŸ“ Move your cursor over windows and drag them around');
58
+ console.log('ā° Test will run for 30 seconds\n');
59
+
60
+ await selector.startSelection();
61
+
62
+ // Periodically log mouse position and compare with overlay state
63
+ const trackingInterval = setInterval(async () => {
64
+ try {
65
+ const status = selector.getStatus();
66
+ const timestamp = Date.now();
67
+
68
+ if (status.nativeStatus?.currentWindow) {
69
+ const window = status.nativeStatus.currentWindow;
70
+ mousePositions.push({
71
+ timestamp,
72
+ windowId: window.id,
73
+ windowPos: { x: window.x, y: window.y },
74
+ windowSize: { width: window.width, height: window.height }
75
+ });
76
+
77
+ // Check for window movement by comparing with previous position
78
+ const prevPos = mousePositions.find(p =>
79
+ p.windowId === window.id &&
80
+ p.timestamp < timestamp - 100 && // at least 100ms ago
81
+ (p.windowPos.x !== window.x || p.windowPos.y !== window.y)
82
+ );
83
+
84
+ if (prevPos) {
85
+ windowMovements.push({
86
+ timestamp,
87
+ windowId: window.id,
88
+ title: window.title,
89
+ from: prevPos.windowPos,
90
+ to: { x: window.x, y: window.y },
91
+ deltaX: window.x - prevPos.windowPos.x,
92
+ deltaY: window.y - prevPos.windowPos.y
93
+ });
94
+
95
+ console.log(`šŸ“ [${new Date(timestamp).toISOString().substr(11,12)}] MOVED: "${window.title}" (${prevPos.windowPos.x}, ${prevPos.windowPos.y}) → (${window.x}, ${window.y}) Ī”(${window.x - prevPos.windowPos.x}, ${window.y - prevPos.windowPos.y})`);
96
+ }
97
+ }
98
+ } catch (err) {
99
+ // Ignore errors during status check
100
+ }
101
+ }, 50); // Check every 50ms for high resolution tracking
102
+
103
+ // Run test for 30 seconds
104
+ await new Promise(resolve => setTimeout(resolve, 30000));
105
+
106
+ clearInterval(trackingInterval);
107
+ console.log('\nā¹ļø Test completed. Analyzing data...\n');
108
+
109
+ // Analysis
110
+ console.log('šŸ“Š ANALYSIS RESULTS:');
111
+ console.log('====================\n');
112
+
113
+ console.log(`šŸ“ Total overlay updates: ${overlayUpdates.length}`);
114
+ console.log(`šŸ“ Total mouse position samples: ${mousePositions.length}`);
115
+ console.log(`šŸ“ Detected window movements: ${windowMovements.length}\n`);
116
+
117
+ // Analyze window movement patterns
118
+ if (windowMovements.length > 0) {
119
+ console.log('šŸ” WINDOW MOVEMENT PATTERNS:');
120
+
121
+ const movementsByWindow = {};
122
+ windowMovements.forEach(move => {
123
+ if (!movementsByWindow[move.windowId]) {
124
+ movementsByWindow[move.windowId] = [];
125
+ }
126
+ movementsByWindow[move.windowId].push(move);
127
+ });
128
+
129
+ for (const [windowId, moves] of Object.entries(movementsByWindow)) {
130
+ const firstMove = moves[0];
131
+ const lastMove = moves[moves.length - 1];
132
+ const totalDeltaX = Math.abs(lastMove.to.x - firstMove.from.x);
133
+ const totalDeltaY = Math.abs(lastMove.to.y - firstMove.from.y);
134
+ const duration = lastMove.timestamp - firstMove.timestamp;
135
+
136
+ console.log(` Window "${firstMove.title}" (ID: ${windowId}):`);
137
+ console.log(` Movements: ${moves.length}`);
138
+ console.log(` Total displacement: (${totalDeltaX}, ${totalDeltaY}) pixels`);
139
+ console.log(` Duration: ${duration}ms`);
140
+ console.log(` Average speed: ${(Math.sqrt(totalDeltaX*totalDeltaX + totalDeltaY*totalDeltaY) / (duration/1000)).toFixed(1)} px/sec\n`);
141
+ }
142
+ }
143
+
144
+ // Analyze update frequency
145
+ if (overlayUpdates.length > 1) {
146
+ console.log('ā±ļø OVERLAY UPDATE TIMING:');
147
+ const intervals = [];
148
+ for (let i = 1; i < overlayUpdates.length; i++) {
149
+ intervals.push(overlayUpdates[i].timestamp - overlayUpdates[i-1].timestamp);
150
+ }
151
+
152
+ if (intervals.length > 0) {
153
+ const avgInterval = intervals.reduce((a, b) => a + b, 0) / intervals.length;
154
+ const minInterval = Math.min(...intervals);
155
+ const maxInterval = Math.max(...intervals);
156
+
157
+ console.log(` Average update interval: ${avgInterval.toFixed(1)}ms (${(1000/avgInterval).toFixed(1)} FPS)`);
158
+ console.log(` Min interval: ${minInterval}ms`);
159
+ console.log(` Max interval: ${maxInterval}ms\n`);
160
+ }
161
+ }
162
+
163
+ } catch (error) {
164
+ console.error('āŒ Test failed:', error.message);
165
+ } finally {
166
+ console.log('šŸ›‘ Cleaning up...');
167
+ await selector.cleanup();
168
+ }
169
+ }
170
+
171
+ if (require.main === module) {
172
+ testOverlayTracking().catch(console.error);
173
+ }
174
+
175
+ module.exports = testOverlayTracking;