eedatek-electron-screenrecord 2.1.4 → 2.1.5
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/lib/index.d.ts +1 -0
- package/lib/index.js +14 -30
- package/lib/preload.js +3 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -45,6 +45,7 @@ class ScreenRecord extends events_1.default {
|
|
|
45
45
|
isRecording = false;
|
|
46
46
|
mouseMoveListener = null;
|
|
47
47
|
scaleFactor = 1;
|
|
48
|
+
sourceId = "";
|
|
48
49
|
constructor(opts) {
|
|
49
50
|
super();
|
|
50
51
|
this.logger = opts?.logger || (0, debug_1.default)("electron-screenshots");
|
|
@@ -286,36 +287,8 @@ class ScreenRecord extends events_1.default {
|
|
|
286
287
|
this.logger("SCREENRECORD:capture Can't find screen source. sources: %o, display: %o", sources, display);
|
|
287
288
|
throw new Error("Can't find screen source");
|
|
288
289
|
}
|
|
290
|
+
this.sourceId = source.id;
|
|
289
291
|
return source.thumbnail.toDataURL();
|
|
290
|
-
// const { Screenshots: NodeScreenshots } = await import('node-screenshots');
|
|
291
|
-
// const capturer = NodeScreenshots.fromPoint(
|
|
292
|
-
// display.x + display.width / 2,
|
|
293
|
-
// display.y + display.height / 2,
|
|
294
|
-
// );
|
|
295
|
-
// this.logger(
|
|
296
|
-
// 'SCREENRECORD:capture NodeScreenshots.fromPoint arguments %o',
|
|
297
|
-
// display,
|
|
298
|
-
// );
|
|
299
|
-
// this.logger(
|
|
300
|
-
// 'SCREENRECORD:capture NodeScreenshots.fromPoint return %o',
|
|
301
|
-
// capturer
|
|
302
|
-
// ? {
|
|
303
|
-
// id: capturer.id,
|
|
304
|
-
// x: capturer.x,
|
|
305
|
-
// y: capturer.y,
|
|
306
|
-
// width: capturer.width,
|
|
307
|
-
// height: capturer.height,
|
|
308
|
-
// rotation: capturer.rotation,
|
|
309
|
-
// scaleFactor: capturer.scaleFactor,
|
|
310
|
-
// isPrimary: capturer.isPrimary,
|
|
311
|
-
// }
|
|
312
|
-
// : null,
|
|
313
|
-
// );
|
|
314
|
-
// if (!capturer) {
|
|
315
|
-
// throw new Error(`NodeScreenshots.fromDisplay(${display.id}) get null`);
|
|
316
|
-
// }
|
|
317
|
-
// const image = await capturer.capture();
|
|
318
|
-
// return `data:image/png;base64,${image.toString('base64')}`;
|
|
319
292
|
}
|
|
320
293
|
catch (err) {
|
|
321
294
|
this.logger("SCREENRECORD:capture NodeScreenshots capture() error %o", err);
|
|
@@ -341,6 +314,7 @@ class ScreenRecord extends events_1.default {
|
|
|
341
314
|
this.logger("SCREENRECORD:capture Can't find screen source. sources: %o, display: %o", sources, display);
|
|
342
315
|
throw new Error("Can't find screen source");
|
|
343
316
|
}
|
|
317
|
+
this.sourceId = source.id;
|
|
344
318
|
return source.thumbnail.toDataURL();
|
|
345
319
|
}
|
|
346
320
|
}
|
|
@@ -413,10 +387,20 @@ class ScreenRecord extends events_1.default {
|
|
|
413
387
|
this.updateButtonBounds(data);
|
|
414
388
|
});
|
|
415
389
|
electron_1.ipcMain.handle("SCREENRECORD:get-desktop-capturer-source", async () => {
|
|
416
|
-
|
|
390
|
+
const sources = [
|
|
417
391
|
...(await electron_1.desktopCapturer.getSources({ types: ["screen", "window"] })),
|
|
418
392
|
...(await selfWindws()),
|
|
419
393
|
];
|
|
394
|
+
if (sources.length > 0) {
|
|
395
|
+
sources.forEach((source) => {
|
|
396
|
+
this.logger("sources name" + source.name + " id:" + source.id);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
return sources;
|
|
400
|
+
});
|
|
401
|
+
electron_1.ipcMain.handle("SCREENRECORD:get-desktop-capturer-source-id", async () => {
|
|
402
|
+
this.logger("sources id:" + this.sourceId);
|
|
403
|
+
return this.sourceId;
|
|
420
404
|
});
|
|
421
405
|
electron_1.ipcMain.handle("SCREENRECORD:get-display-nearest-point", async () => {
|
|
422
406
|
if (this.$win) {
|
package/lib/preload.js
CHANGED
|
@@ -53,6 +53,9 @@ electron_1.contextBridge.exposeInMainWorld('screenshots', {
|
|
|
53
53
|
invokeGetDesktopCapturerSource: () => {
|
|
54
54
|
return electron_1.ipcRenderer.invoke('SCREENRECORD:get-desktop-capturer-source');
|
|
55
55
|
},
|
|
56
|
+
invokeGetDesktopCapturerSourceId: () => {
|
|
57
|
+
return electron_1.ipcRenderer.invoke('SCREENRECORD:get-desktop-capturer-source-id');
|
|
58
|
+
},
|
|
56
59
|
invokeGetDisplayNearestPoint: () => {
|
|
57
60
|
return electron_1.ipcRenderer.invoke('SCREENRECORD:get-display-nearest-point');
|
|
58
61
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eedatek-electron-screenrecord",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "electron 录屏插件",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"main": "lib/index.cjs.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@jitsi/robotjs": "0.6.18",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
|
-
"eedatek-react-screenrecord": "^2.
|
|
37
|
+
"eedatek-react-screenrecord": "^2.1.5",
|
|
38
38
|
"fs-extra": "^11.1.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|