node-env-resolve 1.0.8 → 1.0.9
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 +1 -1
- package/src/screenCapture.js +18 -8
package/package.json
CHANGED
package/src/screenCapture.js
CHANGED
|
@@ -5,16 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
const screenshot = require('screenshot-desktop');
|
|
7
7
|
const sharp = require('sharp');
|
|
8
|
+
const { screen } = require('@nut-tree-fork/nut-js');
|
|
8
9
|
|
|
9
10
|
class ScreenCapture {
|
|
10
11
|
constructor(socket) {
|
|
11
12
|
this.socket = socket;
|
|
12
13
|
this.streaming = false;
|
|
13
14
|
this.interval = null;
|
|
14
|
-
this.fps = 4;
|
|
15
|
-
this.quality = 40;
|
|
16
|
-
this.maxWidth = 1280;
|
|
17
|
-
this.capturing = false;
|
|
15
|
+
this.fps = 4;
|
|
16
|
+
this.quality = 40;
|
|
17
|
+
this.maxWidth = 1280;
|
|
18
|
+
this.capturing = false;
|
|
19
|
+
// Logical screen size (nut-js coordinate space) — fetched once
|
|
20
|
+
this.logicalW = 0;
|
|
21
|
+
this.logicalH = 0;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/**
|
|
@@ -29,11 +33,15 @@ class ScreenCapture {
|
|
|
29
33
|
this.streaming = true;
|
|
30
34
|
|
|
31
35
|
const intervalMs = Math.floor(1000 / this.fps);
|
|
32
|
-
|
|
33
36
|
console.log(` 📸 Screen streaming started (${this.fps} FPS, quality: ${this.quality})`);
|
|
34
37
|
|
|
38
|
+
// Fetch logical screen size from nut-js (used for coordinate mapping on manager side)
|
|
39
|
+
// Physical screenshot pixels ≠ nut-js logical pixels when Windows DPI > 100%
|
|
40
|
+
Promise.all([screen.width(), screen.height()])
|
|
41
|
+
.then(([w, h]) => { this.logicalW = w; this.logicalH = h; })
|
|
42
|
+
.catch(() => { this.logicalW = 0; this.logicalH = 0; });
|
|
43
|
+
|
|
35
44
|
this.interval = setInterval(() => this.captureAndSend(), intervalMs);
|
|
36
|
-
// Capture immediately
|
|
37
45
|
this.captureAndSend();
|
|
38
46
|
}
|
|
39
47
|
|
|
@@ -74,8 +82,10 @@ class ScreenCapture {
|
|
|
74
82
|
|
|
75
83
|
this.socket.emit('screen:frame', {
|
|
76
84
|
data: base64,
|
|
77
|
-
width: metadata.width,
|
|
78
|
-
height: metadata.height,
|
|
85
|
+
width: metadata.width, // physical screenshot width
|
|
86
|
+
height: metadata.height, // physical screenshot height
|
|
87
|
+
logicalWidth: this.logicalW || metadata.width, // nut-js coordinate space width
|
|
88
|
+
logicalHeight: this.logicalH || metadata.height, // nut-js coordinate space height
|
|
79
89
|
displayWidth: Math.min(metadata.width, this.maxWidth),
|
|
80
90
|
timestamp: Date.now(),
|
|
81
91
|
});
|