electron-screenshots 0.5.27 → 0.6.0

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 CHANGED
@@ -1,231 +1,248 @@
1
- # electron-screenshots
2
-
3
- > electron 截图插件
4
-
5
- ## Prerequisites
6
-
7
- - electron >= 11
8
-
9
- ## Install
10
-
11
- [![NPM](https://nodei.co/npm/electron-screenshots.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/electron-screenshots/)
12
-
13
- ## Usage
14
-
15
- ```ts
16
- import debug from "electron-debug";
17
- import { app, globalShortcut } from "electron";
18
- import Screenshots from "./screenshots";
19
-
20
- app.whenReady().then(() => {
21
- const screenshots = new Screenshots();
22
- globalShortcut.register("ctrl+shift+a", () => {
23
- screenshots.startCapture();
24
- screenshots.$view.webContents.openDevTools();
25
- });
26
- // 点击确定按钮回调事件
27
- screenshots.on("ok", (e, buffer, bounds) => {
28
- console.log("capture", buffer, bounds);
29
- });
30
- // 点击取消按钮回调事件
31
- screenshots.on("cancel", () => {
32
- console.log("capture", "cancel1");
33
- });
34
- screenshots.on("cancel", (e) => {
35
- // 执行了preventDefault
36
- // 点击取消不会关闭截图窗口
37
- e.preventDefault();
38
- console.log("capture", "cancel2");
39
- });
40
- // 点击保存按钮回调事件
41
- screenshots.on("save", (e, buffer, bounds) => {
42
- console.log("capture", buffer, bounds);
43
- });
44
- // 保存后的回调事件
45
- screenshots.on("afterSave", (e, buffer, bounds, isSaved) => {
46
- console.log("capture", buffer, bounds);
47
- console.log("isSaved", isSaved) // 是否保存成功
48
- });
49
- debug({ showDevTools: true, devToolsMode: "undocked" });
50
- });
51
-
52
- app.on("window-all-closed", () => {
53
- if (process.platform !== "darwin") {
54
- app.quit();
55
- }
56
- });
57
- ```
58
-
59
- ### 注意
60
-
61
- - 如果使用了 webpack 打包主进程,请在主进程 webpack 配置中修改如下配置,否则可能会出现不能调用截图窗口的情况
62
-
63
- ```js
64
- {
65
- externals: {
66
- 'electron-screenshots': 'require("electron-screenshots")'
67
- }
68
- }
69
- ```
70
-
71
- - `vue-cli-plugin-electron-builder`配置示例[vue-cli-plugin-electron-builder-issue](https://github.com/nashaofu/vue-cli-plugin-electron-builder-issue/blob/0f774a90b09e10b02f86fcb6b50645058fe1a4e8/vue.config.js#L1-L8)
72
-
73
- ```js
74
- // vue.config.js
75
- module.exports = {
76
- publicPath: ".",
77
- pluginOptions: {
78
- electronBuilder: {
79
- // 不打包,使用 require 加载
80
- externals: ["electron-screenshots"],
81
- },
82
- },
83
- };
84
- ```
85
-
86
- - esc 取消截图,可用以下代码实现按 esc 取消截图
87
-
88
- ```js
89
- globalShortcut.register("esc", () => {
90
- if (screenshots.$win?.isFocused()) {
91
- screenshots.endCapture();
92
- }
93
- });
94
- ```
95
-
96
- - 加速截图界面展示,不销毁`BrowserWindow`,减少创建窗口的开销,可用以下代码实现。**需注意,启用该功能,会导致`window-all-closed`事件不触发,因此需要手动关闭截图窗口**
97
-
98
- ```js
99
- // 是否复用截图窗口,加快截图窗口显示,默认值为 false
100
- // 如果设置为 true 则会在第一次调用截图窗口时创建,后续调用时直接使用
101
- // 且由于窗口不会 close,所以不会触发 app 的 `window-all-closed` 事件
102
- const screenshots = new Screenshots({
103
- singleWindow: true,
104
- });
105
- ```
106
-
107
- ## Methods
108
-
109
- - `Debugger`类型产考[debug](https://github.com/debug-js/debug)中的`Debugger`类型
110
-
111
- ```ts
112
- export type LoggerFn = (...args: unknown[]) => void;
113
- export type Logger = Debugger | LoggerFn;
114
-
115
- export interface Lang {
116
- magnifier_position_label?: string;
117
- operation_ok_title?: string;
118
- operation_cancel_title?: string;
119
- operation_save_title?: string;
120
- operation_redo_title?: string;
121
- operation_undo_title?: string;
122
- operation_mosaic_title?: string;
123
- operation_text_title?: string;
124
- operation_brush_title?: string;
125
- operation_arrow_title?: string;
126
- operation_ellipse_title?: string;
127
- operation_rectangle_title?: string;
128
- }
129
-
130
- export interface ScreenshotsOpts {
131
- lang?: Lang;
132
- // 调用日志,默认值为 debug('electron-screenshots')
133
- // debug https://www.npmjs.com/package/debug
134
- logger?: Logger;
135
- // 是否复用截图窗口,加快截图窗口显示,默认值为 false
136
- // 如果设置为 true 则会在第一次调用截图窗口时创建,后续调用时直接使用
137
- // 且由于窗口不会 close,所以不会触发 app 的 `window-all-closed` 事件
138
- singleWindow?: boolean;
139
- }
140
- ```
141
-
142
- | 名称 | 说明 | 返回值 |
143
- | ------------------------------------------------- | ---------------- | ------ |
144
- | `constructor(opts: ScreenshotsOpts): Screenshots` | 调用截图方法截图 | - |
145
- | `startCapture(): Promise<void>` | 调用截图方法截图 | - |
146
- | `endCapture(): Promise<void>` | 手动结束截图 | - |
147
- | `setLang(lang: Lang): Promise<void>` | 修改语言 | - |
148
-
149
- ## Events
150
-
151
- - 数据类型
152
-
153
- ```ts
154
- interface Bounds {
155
- x: number;
156
- y: number;
157
- width: number;
158
- height: number;
159
- }
160
-
161
- export interface Display {
162
- id: number;
163
- x: number;
164
- y: number;
165
- width: number;
166
- height: number;
167
- }
168
-
169
- export interface ScreenshotsData {
170
- bounds: Bounds;
171
- display: Display;
172
- }
173
-
174
- class Event {
175
- public defaultPrevented = false;
176
-
177
- public preventDefault(): void {
178
- this.defaultPrevented = true;
179
- }
180
- }
181
- ```
182
-
183
- | 名称 | 说明 | 回调参数 |
184
- | ------------- | ----------------------------------------------------------- | --------------------------------------------------------------------------------- |
185
- | ok | 截图确认事件 | `(event: Event, buffer: Buffer, data: ScreenshotsData) => void` |
186
- | cancel | 截图取消事件 | `(event: Event) => void` |
187
- | save | 截图保存事件 | `(event: Event, buffer: Buffer, data: ScreenshotsData) => void` |
188
- | afterSave | 截图保存(取消保存)后的事件 | `(event: Event, buffer: Buffer, data: ScreenshotsData, isSaved: boolean) => void` |
189
- | windowCreated | 截图窗口被创建后触发 | `($win: BrowserWindow) => void` |
190
- | windowClosed | 截图窗口被关闭后触发,对`BrowserWindow` `closed` 事件的转发 | `($win: BrowserWindow) => void` |
191
-
192
- ### 说明
193
-
194
- - event: 事件对象
195
- - buffer: png 图片 buffer
196
- - bounds: 截图区域信息
197
- - display: 截图的屏幕
198
- - `event`对象可调用`preventDefault`方法来阻止默认事件,例如阻止默认保存事件
199
-
200
- ```ts
201
- const screenshots = new Screenshots({
202
- lang: {
203
- magnifier_position_label: "Position",
204
- operation_ok_title: "Ok",
205
- operation_cancel_title: "Cancel",
206
- operation_save_title: "Save",
207
- operation_redo_title: "Redo",
208
- operation_undo_title: "Undo",
209
- operation_mosaic_title: "Mosaic",
210
- operation_text_title: "Text",
211
- operation_brush_title: "Brush",
212
- operation_arrow_title: "Arrow",
213
- operation_ellipse_title: "Ellipse",
214
- operation_rectangle_title: "Rectangle",
215
- },
216
- });
217
-
218
- screenshots.on("save", (e, buffer, data) => {
219
- // 阻止插件自带的保存功能
220
- // 用户自己控制保存功能
221
- e.preventDefault();
222
- // 用户可在这里自己定义保存功能
223
- console.log("capture", buffer, data);
224
- });
225
-
226
- screenshots.startCapture();
227
- ```
228
-
229
- ## Screenshot
230
-
231
- ![screenshot](../../screenshot.jpg)
1
+ # electron-screenshots
2
+
3
+ > electron 截图插件
4
+
5
+ ## Prerequisites
6
+
7
+ - electron >= 11
8
+
9
+ ## Install
10
+
11
+ [![NPM](https://nodei.co/npm/electron-screenshots.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/electron-screenshots/)
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import debug from "electron-debug";
17
+ import { app, globalShortcut } from "electron";
18
+ import Screenshots from "./screenshots";
19
+
20
+ app.whenReady().then(() => {
21
+ app.setAppUserModelId('com.electron.screenshots')
22
+ const screenshots = new Screenshots();
23
+ globalShortcut.register("ctrl+shift+a", () => {
24
+ screenshots.startCapture();
25
+ screenshots.$view.webContents.openDevTools();
26
+ });
27
+ // 点击确定按钮回调事件
28
+ screenshots.on("ok", (e, buffer, bounds) => {
29
+ console.log("capture", buffer, bounds);
30
+ });
31
+ // 点击取消按钮回调事件
32
+ screenshots.on("cancel", () => {
33
+ console.log("capture", "cancel1");
34
+ });
35
+ screenshots.on("cancel", (e) => {
36
+ // 执行了preventDefault
37
+ // 点击取消不会关闭截图窗口
38
+ e.preventDefault();
39
+ console.log("capture", "cancel2");
40
+ });
41
+ // 点击保存按钮回调事件
42
+ screenshots.on("save", (e, buffer, bounds) => {
43
+ console.log("capture", buffer, bounds);
44
+ });
45
+ // 保存后的回调事件
46
+ screenshots.on("afterSave", (e, buffer, bounds, isSaved) => {
47
+ console.log("capture", buffer, bounds);
48
+ console.log("isSaved", isSaved); // 是否保存成功
49
+ });
50
+ debug({ showDevTools: true, devToolsMode: "undocked" });
51
+ });
52
+
53
+ app.on("window-all-closed", () => {
54
+ if (process.platform !== "darwin") {
55
+ app.quit();
56
+ }
57
+ });
58
+ ```
59
+
60
+ ### 注意
61
+
62
+ - 如果使用了 webpack 打包主进程,请在主进程 webpack 配置中修改如下配置,否则可能会出现不能调用截图窗口的情况
63
+
64
+ ```js
65
+ {
66
+ externals: {
67
+ 'electron-screenshots': 'require("electron-screenshots")'
68
+ }
69
+ }
70
+ ```
71
+
72
+ - `vue-cli-plugin-electron-builder`配置示例[vue-cli-plugin-electron-builder-issue](https://github.com/nashaofu/vue-cli-plugin-electron-builder-issue/blob/0f774a90b09e10b02f86fcb6b50645058fe1a4e8/vue.config.js#L1-L8)
73
+
74
+ ```js
75
+ // vue.config.js
76
+ module.exports = {
77
+ publicPath: ".",
78
+ pluginOptions: {
79
+ electronBuilder: {
80
+ // 不打包,使用 require 加载
81
+ externals: ["electron-screenshots"],
82
+ },
83
+ },
84
+ };
85
+ ```
86
+
87
+ - vite 配置示例:
88
+
89
+ ```js
90
+ // vite.config.js
91
+ import { defineConfig } from "vite";
92
+ import viteExternals from "vite-plugin-externals";
93
+
94
+ export default defineConfig({
95
+ plugins: [
96
+ viteExternals({
97
+ "electron-screenshots": 'require("electron-screenshots")', // 模块名称: 全局变量
98
+ }),
99
+ ],
100
+ });
101
+ ```
102
+
103
+ - esc 取消截图,可用以下代码实现按 esc 取消截图
104
+
105
+ ```js
106
+ globalShortcut.register("esc", () => {
107
+ if (screenshots.$win?.isFocused()) {
108
+ screenshots.endCapture();
109
+ }
110
+ });
111
+ ```
112
+
113
+ - 加速截图界面展示,不销毁`BrowserWindow`,减少创建窗口的开销,可用以下代码实现。**需注意,启用该功能,会导致`window-all-closed`事件不触发,因此需要手动关闭截图窗口**
114
+
115
+ ```js
116
+ // 是否复用截图窗口,加快截图窗口显示,默认值为 false
117
+ // 如果设置为 true 则会在第一次调用截图窗口时创建,后续调用时直接使用
118
+ // 且由于窗口不会 close,所以不会触发 app 的 `window-all-closed` 事件
119
+ const screenshots = new Screenshots({
120
+ singleWindow: true,
121
+ });
122
+ ```
123
+
124
+ ## Methods
125
+
126
+ - `Debugger`类型产考[debug](https://github.com/debug-js/debug)中的`Debugger`类型
127
+
128
+ ```ts
129
+ export type LoggerFn = (...args: unknown[]) => void;
130
+ export type Logger = Debugger | LoggerFn;
131
+
132
+ export interface Lang {
133
+ magnifier_position_label?: string;
134
+ operation_ok_title?: string;
135
+ operation_cancel_title?: string;
136
+ operation_save_title?: string;
137
+ operation_redo_title?: string;
138
+ operation_undo_title?: string;
139
+ operation_mosaic_title?: string;
140
+ operation_text_title?: string;
141
+ operation_brush_title?: string;
142
+ operation_arrow_title?: string;
143
+ operation_ellipse_title?: string;
144
+ operation_rectangle_title?: string;
145
+ }
146
+
147
+ export interface ScreenshotsOpts {
148
+ lang?: Lang;
149
+ // 调用日志,默认值为 debug('electron-screenshots')
150
+ // debug https://www.npmjs.com/package/debug
151
+ logger?: Logger;
152
+ // 是否复用截图窗口,加快截图窗口显示,默认值为 false
153
+ // 如果设置为 true 则会在第一次调用截图窗口时创建,后续调用时直接使用
154
+ // 且由于窗口不会 close,所以不会触发 app 的 `window-all-closed` 事件
155
+ singleWindow?: boolean;
156
+ }
157
+ ```
158
+
159
+ | 名称 | 说明 | 返回值 |
160
+ | ------------------------------------------------- | ---------------- | ------ |
161
+ | `constructor(opts: ScreenshotsOpts): Screenshots` | 调用截图方法截图 | - |
162
+ | `startCapture(): Promise<void>` | 调用截图方法截图 | - |
163
+ | `endCapture(): Promise<void>` | 手动结束截图 | - |
164
+ | `setLang(lang: Lang): Promise<void>` | 修改语言 | - |
165
+
166
+ ## Events
167
+
168
+ - 数据类型
169
+
170
+ ```ts
171
+ interface Bounds {
172
+ x: number;
173
+ y: number;
174
+ width: number;
175
+ height: number;
176
+ }
177
+
178
+ export interface Display {
179
+ id: number;
180
+ x: number;
181
+ y: number;
182
+ width: number;
183
+ height: number;
184
+ }
185
+
186
+ export interface ScreenshotsData {
187
+ bounds: Bounds;
188
+ display: Display;
189
+ }
190
+
191
+ class Event {
192
+ public defaultPrevented = false;
193
+
194
+ public preventDefault(): void {
195
+ this.defaultPrevented = true;
196
+ }
197
+ }
198
+ ```
199
+
200
+ | 名称 | 说明 | 回调参数 |
201
+ | ------------- | ----------------------------------------------------------- | --------------------------------------------------------------------------------- |
202
+ | ok | 截图确认事件 | `(event: Event, buffer: Buffer, data: ScreenshotsData) => void` |
203
+ | cancel | 截图取消事件 | `(event: Event) => void` |
204
+ | save | 截图保存事件 | `(event: Event, buffer: Buffer, data: ScreenshotsData) => void` |
205
+ | afterSave | 截图保存(取消保存)后的事件 | `(event: Event, buffer: Buffer, data: ScreenshotsData, isSaved: boolean) => void` |
206
+ | windowCreated | 截图窗口被创建后触发 | `($win: BrowserWindow) => void` |
207
+ | windowClosed | 截图窗口被关闭后触发,对`BrowserWindow` `closed` 事件的转发 | `($win: BrowserWindow) => void` |
208
+
209
+ ### 说明
210
+
211
+ - event: 事件对象
212
+ - buffer: png 图片 buffer
213
+ - bounds: 截图区域信息
214
+ - display: 截图的屏幕
215
+ - `event`对象可调用`preventDefault`方法来阻止默认事件,例如阻止默认保存事件
216
+
217
+ ```ts
218
+ const screenshots = new Screenshots({
219
+ lang: {
220
+ magnifier_position_label: "Position",
221
+ operation_ok_title: "Ok",
222
+ operation_cancel_title: "Cancel",
223
+ operation_save_title: "Save",
224
+ operation_redo_title: "Redo",
225
+ operation_undo_title: "Undo",
226
+ operation_mosaic_title: "Mosaic",
227
+ operation_text_title: "Text",
228
+ operation_brush_title: "Brush",
229
+ operation_arrow_title: "Arrow",
230
+ operation_ellipse_title: "Ellipse",
231
+ operation_rectangle_title: "Rectangle",
232
+ },
233
+ });
234
+
235
+ screenshots.on("save", (e, buffer, data) => {
236
+ // 阻止插件自带的保存功能
237
+ // 用户自己控制保存功能
238
+ e.preventDefault();
239
+ // 用户可在这里自己定义保存功能
240
+ console.log("capture", buffer, data);
241
+ });
242
+
243
+ screenshots.startCapture();
244
+ ```
245
+
246
+ ## Screenshot
247
+
248
+ ![screenshot](../../screenshot.jpg)
package/lib/demo.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=demo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":""}
package/lib/demo.js CHANGED
@@ -4,41 +4,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* eslint-disable no-console */
7
- var electron_1 = require("electron");
8
- var _1 = __importDefault(require("."));
9
- electron_1.app.whenReady().then(function () {
10
- var screenshots = new _1.default({
7
+ const electron_1 = require("electron");
8
+ const index_js_1 = __importDefault(require("./index.js"));
9
+ electron_1.app.whenReady().then(() => {
10
+ const screenshots = new index_js_1.default({
11
11
  lang: {
12
12
  operation_rectangle_title: '矩形2323',
13
13
  },
14
14
  singleWindow: true,
15
15
  });
16
16
  screenshots.$view.webContents.openDevTools();
17
- electron_1.globalShortcut.register('ctrl+shift+a', function () {
17
+ electron_1.globalShortcut.register('ctrl+shift+a', () => {
18
18
  screenshots.startCapture();
19
19
  });
20
- screenshots.on('windowCreated', function ($win) {
21
- $win.on('focus', function () {
22
- electron_1.globalShortcut.register('esc', function () {
20
+ screenshots.on('windowCreated', ($win) => {
21
+ $win.on('focus', () => {
22
+ electron_1.globalShortcut.register('esc', () => {
23
23
  if ($win === null || $win === void 0 ? void 0 : $win.isFocused()) {
24
24
  screenshots.endCapture();
25
25
  }
26
26
  });
27
27
  });
28
- $win.on('blur', function () {
28
+ $win.on('blur', () => {
29
29
  electron_1.globalShortcut.unregister('esc');
30
30
  });
31
31
  });
32
32
  // 防止不能关闭截图界面
33
- electron_1.globalShortcut.register('ctrl+shift+q', function () {
33
+ electron_1.globalShortcut.register('ctrl+shift+q', () => {
34
34
  electron_1.app.quit();
35
35
  });
36
36
  // 点击确定按钮回调事件
37
- screenshots.on('ok', function (e, buffer, bounds) {
37
+ screenshots.on('ok', (e, buffer, bounds) => {
38
38
  console.log('capture', buffer, bounds);
39
39
  });
40
40
  // 点击取消按钮回调事件
41
- screenshots.on('cancel', function () {
41
+ screenshots.on('cancel', () => {
42
42
  console.log('capture', 'cancel1');
43
43
  screenshots.setLang({
44
44
  operation_ellipse_title: 'ellipse',
@@ -46,17 +46,18 @@ electron_1.app.whenReady().then(function () {
46
46
  });
47
47
  });
48
48
  // 点击保存按钮回调事件
49
- screenshots.on('save', function (e, buffer, bounds) {
49
+ screenshots.on('save', (e, buffer, bounds) => {
50
50
  console.log('capture', buffer, bounds);
51
51
  });
52
- var mainWin = new electron_1.BrowserWindow({
52
+ const mainWin = new electron_1.BrowserWindow({
53
53
  show: true,
54
54
  });
55
55
  mainWin.removeMenu();
56
56
  mainWin.loadURL('https://github.com/nashaofu');
57
57
  });
58
- electron_1.app.on('window-all-closed', function () {
58
+ electron_1.app.on('window-all-closed', () => {
59
59
  if (process.platform !== 'darwin') {
60
60
  electron_1.app.quit();
61
61
  }
62
62
  });
63
+ //# sourceMappingURL=demo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo.js","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B,uCAA8D;AAC9D,0DAAqC;AAErC,cAAG,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;IACxB,MAAM,WAAW,GAAG,IAAI,kBAAW,CAAC;QAClC,IAAI,EAAE;YACJ,yBAAyB,EAAE,QAAQ;SACpC;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IACH,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;IAE7C,yBAAc,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC3C,WAAW,CAAC,YAAY,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;QACvC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACpB,yBAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;gBAClC,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,EAAE,EAAE,CAAC;oBACtB,WAAW,CAAC,UAAU,EAAE,CAAC;gBAC3B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACnB,yBAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,aAAa;IACb,yBAAc,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC3C,cAAG,CAAC,IAAI,EAAE,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,aAAa;IACb,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QACzC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,aAAa;IACb,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAClC,WAAW,CAAC,OAAO,CAAC;YAClB,uBAAuB,EAAE,SAAS;YAClC,yBAAyB,EAAE,WAAW;SACvC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,aAAa;IACb,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QAC3C,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAI,wBAAa,CAAC;QAChC,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IACH,OAAO,CAAC,UAAU,EAAE,CAAC;IACrB,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AAEH,cAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,cAAG,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;AACH,CAAC,CAAC,CAAC"}
package/lib/event.d.ts CHANGED
@@ -2,3 +2,4 @@ export default class Event {
2
2
  defaultPrevented: boolean;
3
3
  preventDefault(): void;
4
4
  }
5
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,KAAK;IACjB,gBAAgB,UAAS;IAEzB,cAAc,IAAI,IAAI;CAG9B"}
package/lib/event.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var Event = /** @class */ (function () {
4
- function Event() {
3
+ class Event {
4
+ constructor() {
5
5
  this.defaultPrevented = false;
6
6
  }
7
- Event.prototype.preventDefault = function () {
7
+ preventDefault() {
8
8
  this.defaultPrevented = true;
9
- };
10
- return Event;
11
- }());
9
+ }
10
+ }
12
11
  exports.default = Event;
12
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":";;AAAA,MAAqB,KAAK;IAA1B;QACS,qBAAgB,GAAG,KAAK,CAAC;IAKlC,CAAC;IAHQ,cAAc;QACnB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF;AAND,wBAMC"}
@@ -1,7 +1,8 @@
1
- import { Rectangle } from 'electron';
1
+ import { type Rectangle } from "electron";
2
2
  export interface Display extends Rectangle {
3
3
  id: number;
4
4
  scaleFactor: number;
5
5
  }
6
6
  declare const _default: () => Display;
7
7
  export default _default;
8
+ //# sourceMappingURL=getDisplay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDisplay.d.ts","sourceRoot":"","sources":["../src/getDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,OAAQ,SAAQ,SAAS;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;8BAEkB,OAAO;AAA1B,wBAaE"}
package/lib/getDisplay.js CHANGED
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var electron_1 = require("electron");
4
- exports.default = (function () {
5
- var point = electron_1.screen.getCursorScreenPoint();
6
- var _a = electron_1.screen.getDisplayNearestPoint(point), id = _a.id, bounds = _a.bounds, scaleFactor = _a.scaleFactor;
3
+ const electron_1 = require("electron");
4
+ exports.default = () => {
5
+ const point = electron_1.screen.getCursorScreenPoint();
6
+ const { id, bounds, scaleFactor } = electron_1.screen.getDisplayNearestPoint(point);
7
7
  // https://github.com/nashaofu/screenshots/issues/98
8
8
  return {
9
- id: id,
9
+ id,
10
10
  x: Math.floor(bounds.x),
11
11
  y: Math.floor(bounds.y),
12
12
  width: Math.floor(bounds.width),
13
13
  height: Math.floor(bounds.height),
14
- scaleFactor: scaleFactor,
14
+ scaleFactor,
15
15
  };
16
- });
16
+ };
17
+ //# sourceMappingURL=getDisplay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDisplay.js","sourceRoot":"","sources":["../src/getDisplay.ts"],"names":[],"mappings":";;AAAA,uCAAkD;AAOlD,kBAAe,GAAY,EAAE;IAC3B,MAAM,KAAK,GAAG,iBAAM,CAAC,oBAAoB,EAAE,CAAC;IAC5C,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,iBAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAEzE,oDAAoD;IACpD,OAAO;QACL,EAAE;QACF,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACvB,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QACjC,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC"}