electron-screenshots 0.4.1 → 0.4.2
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/README.md +21 -6
- package/lib/preload.d.ts +6 -1
- package/lib/screenshots.d.ts +18 -4
- package/lib/screenshots.js +8 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -80,14 +80,29 @@ module.exports = {
|
|
|
80
80
|
|
|
81
81
|
## Methods
|
|
82
82
|
|
|
83
|
-
- `
|
|
84
|
-
- `Lang`类型产考`react-screenshots`中的`Lang`类型
|
|
83
|
+
- `Debugger`类型产考`debug`中的`Debugger`类型
|
|
85
84
|
|
|
86
85
|
```ts
|
|
87
86
|
export type LoggerFn = (...args: unknown[]) => void
|
|
88
87
|
export type Logger = Debugger | LoggerFn
|
|
88
|
+
|
|
89
|
+
export interface Lang {
|
|
90
|
+
magnifier_position_label?: string
|
|
91
|
+
operation_ok_title?: string
|
|
92
|
+
operation_cancel_title?: string
|
|
93
|
+
operation_save_title?: string
|
|
94
|
+
operation_redo_title?: string
|
|
95
|
+
operation_undo_title?: string
|
|
96
|
+
operation_mosaic_title?: string
|
|
97
|
+
operation_text_title?: string
|
|
98
|
+
operation_brush_title?: string
|
|
99
|
+
operation_arrow_title?: string
|
|
100
|
+
operation_ellipse_title?: string
|
|
101
|
+
operation_rectangle_title?: string
|
|
102
|
+
}
|
|
103
|
+
|
|
89
104
|
export interface ScreenshotsOpts {
|
|
90
|
-
lang?:
|
|
105
|
+
lang?: Lang
|
|
91
106
|
// 调用日志,默认值为 debug('electron-screenshots')
|
|
92
107
|
// debug https://www.npmjs.com/package/debug
|
|
93
108
|
logger?: Logger
|
|
@@ -99,7 +114,7 @@ export interface ScreenshotsOpts {
|
|
|
99
114
|
| `constructor(opts: ScreenshotsOpts)` | 调用截图方法截图 | - |
|
|
100
115
|
| `startCapture()` | 调用截图方法截图 | - |
|
|
101
116
|
| `endCapture() ` | 手动结束截图 | - |
|
|
102
|
-
| `setLang(lang:
|
|
117
|
+
| `setLang(lang: Lang)` | 修改语言 | - |
|
|
103
118
|
|
|
104
119
|
## Events
|
|
105
120
|
|
|
@@ -167,12 +182,12 @@ const screenshots = new Screenshots({
|
|
|
167
182
|
}
|
|
168
183
|
})
|
|
169
184
|
|
|
170
|
-
screenshots.on('save', (e, buffer,
|
|
185
|
+
screenshots.on('save', (e, buffer, data) => {
|
|
171
186
|
// 阻止插件自带的保存功能
|
|
172
187
|
// 用户自己控制保存功能
|
|
173
188
|
e.preventDefault()
|
|
174
189
|
// 用户可在这里自己定义保存功能
|
|
175
|
-
console.log('capture', buffer,
|
|
190
|
+
console.log('capture', buffer, data)
|
|
176
191
|
})
|
|
177
192
|
|
|
178
193
|
screenshots.startCapture()
|
package/lib/preload.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Display } from './getBoundAndDisplay';
|
|
2
|
-
|
|
2
|
+
export interface Bounds {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
3
8
|
export interface ScreenshotsData {
|
|
4
9
|
bounds: Bounds;
|
|
5
10
|
display: Display;
|
package/lib/screenshots.d.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Debugger } from 'debug';
|
|
3
|
-
import {
|
|
3
|
+
import { BrowserView, BrowserWindow } from 'electron';
|
|
4
4
|
import Events from 'events';
|
|
5
|
-
import { Bounds
|
|
5
|
+
import { Bounds } from './preload';
|
|
6
6
|
export declare type LoggerFn = (...args: unknown[]) => void;
|
|
7
7
|
export declare type Logger = Debugger | LoggerFn;
|
|
8
|
+
export interface Lang {
|
|
9
|
+
magnifier_position_label?: string;
|
|
10
|
+
operation_ok_title?: string;
|
|
11
|
+
operation_cancel_title?: string;
|
|
12
|
+
operation_save_title?: string;
|
|
13
|
+
operation_redo_title?: string;
|
|
14
|
+
operation_undo_title?: string;
|
|
15
|
+
operation_mosaic_title?: string;
|
|
16
|
+
operation_text_title?: string;
|
|
17
|
+
operation_brush_title?: string;
|
|
18
|
+
operation_arrow_title?: string;
|
|
19
|
+
operation_ellipse_title?: string;
|
|
20
|
+
operation_rectangle_title?: string;
|
|
21
|
+
}
|
|
8
22
|
export interface ScreenshotsOpts {
|
|
9
|
-
lang?:
|
|
23
|
+
lang?: Lang;
|
|
10
24
|
logger?: Logger;
|
|
11
25
|
}
|
|
12
|
-
export { Bounds
|
|
26
|
+
export { Bounds };
|
|
13
27
|
export default class Screenshots extends Events {
|
|
14
28
|
$win: BrowserWindow | null;
|
|
15
29
|
$view: BrowserView;
|
package/lib/screenshots.js
CHANGED
|
@@ -75,11 +75,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
75
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
76
|
var debug_1 = __importDefault(require("debug"));
|
|
77
77
|
var electron_1 = require("electron");
|
|
78
|
+
var events_1 = __importDefault(require("events"));
|
|
78
79
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
79
80
|
var event_1 = __importDefault(require("./event"));
|
|
80
|
-
var events_1 = __importDefault(require("events"));
|
|
81
|
-
var padStart_1 = __importDefault(require("./padStart"));
|
|
82
81
|
var getBoundAndDisplay_1 = __importDefault(require("./getBoundAndDisplay"));
|
|
82
|
+
var padStart_1 = __importDefault(require("./padStart"));
|
|
83
83
|
var Screenshots = /** @class */ (function (_super) {
|
|
84
84
|
__extends(Screenshots, _super);
|
|
85
85
|
function Screenshots(opts) {
|
|
@@ -262,10 +262,10 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
262
262
|
/**
|
|
263
263
|
* OK事件
|
|
264
264
|
*/
|
|
265
|
-
electron_1.ipcMain.on('SCREENSHOTS:ok', function (e, buffer,
|
|
266
|
-
_this.logger('SCREENSHOTS:ok', buffer,
|
|
265
|
+
electron_1.ipcMain.on('SCREENSHOTS:ok', function (e, buffer, data) {
|
|
266
|
+
_this.logger('SCREENSHOTS:ok', buffer, data);
|
|
267
267
|
var event = new event_1.default();
|
|
268
|
-
_this.emit('ok', event, buffer,
|
|
268
|
+
_this.emit('ok', event, buffer, data);
|
|
269
269
|
if (event.defaultPrevented) {
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
@@ -287,14 +287,14 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
287
287
|
/**
|
|
288
288
|
* SAVE事件
|
|
289
289
|
*/
|
|
290
|
-
electron_1.ipcMain.on('SCREENSHOTS:save', function (e, buffer,
|
|
290
|
+
electron_1.ipcMain.on('SCREENSHOTS:save', function (e, buffer, data) { return __awaiter(_this, void 0, void 0, function () {
|
|
291
291
|
var event, time, year, month, date, hours, minutes, seconds, milliseconds, _a, canceled, filePath;
|
|
292
292
|
return __generator(this, function (_b) {
|
|
293
293
|
switch (_b.label) {
|
|
294
294
|
case 0:
|
|
295
|
-
this.logger('SCREENSHOTS:save', buffer,
|
|
295
|
+
this.logger('SCREENSHOTS:save', buffer, data);
|
|
296
296
|
event = new event_1.default();
|
|
297
|
-
this.emit('save', event, buffer,
|
|
297
|
+
this.emit('save', event, buffer, data);
|
|
298
298
|
if (event.defaultPrevented || !this.$win) {
|
|
299
299
|
return [2 /*return*/];
|
|
300
300
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-screenshots",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "electron 截图插件",
|
|
5
5
|
"types": "lib/screenshots.d.ts",
|
|
6
6
|
"main": "lib/screenshots.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"debug": "^4.3.3",
|
|
39
39
|
"fs-extra": "^10.1.0",
|
|
40
|
-
"node-screenshots": "^0.0.
|
|
40
|
+
"node-screenshots": "^0.0.3",
|
|
41
41
|
"react-screenshots": "^0.4.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"rimraf": "^3.0.2",
|
|
60
60
|
"typescript": "^4.5.5"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "a518f3ba2a36ff0e116ebf90d180157b27a39fc3"
|
|
63
63
|
}
|