@ohos-ports/electron-screenshots 0.6.2-beta.1
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 +15 -0
- package/lib/demo.d.ts +2 -0
- package/lib/demo.d.ts.map +1 -0
- package/lib/demo.js +63 -0
- package/lib/demo.js.map +1 -0
- package/lib/event.d.ts +5 -0
- package/lib/event.d.ts.map +1 -0
- package/lib/event.js +12 -0
- package/lib/event.js.map +1 -0
- package/lib/getDisplay.d.ts +8 -0
- package/lib/getDisplay.d.ts.map +1 -0
- package/lib/getDisplay.js +17 -0
- package/lib/getDisplay.js.map +1 -0
- package/lib/index.cjs.d.ts +2 -0
- package/lib/index.cjs.d.ts.map +1 -0
- package/lib/index.cjs.js +4 -0
- package/lib/index.cjs.js.map +1 -0
- package/lib/index.d.ts +57 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +338 -0
- package/lib/index.js.map +1 -0
- package/lib/padStart.d.ts +9 -0
- package/lib/padStart.d.ts.map +1 -0
- package/lib/padStart.js +18 -0
- package/lib/padStart.js.map +1 -0
- package/lib/preload.d.ts +12 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +51 -0
- package/lib/preload.js.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@ohos-ports/electron-screenshots
|
|
2
|
+
|
|
3
|
+
Electron screenshots plugin for OHOS (OpenHarmony).
|
|
4
|
+
|
|
5
|
+
Fork of electron-screenshots with OHOS adaptation:
|
|
6
|
+
- Uses @ohos-ports/ohos-screenshots instead of node-screenshots on OHOS
|
|
7
|
+
- Adds openharmony window type support
|
|
8
|
+
- Falls back to node-screenshots on Windows/macOS/Linux
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @ohos-ports/electron-screenshots
|
|
14
|
+
```
|
|
15
|
+
|
package/lib/demo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":""}
|
package/lib/demo.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/* eslint-disable no-console */
|
|
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
|
+
lang: {
|
|
12
|
+
operation_rectangle_title: '矩形2323',
|
|
13
|
+
},
|
|
14
|
+
singleWindow: true,
|
|
15
|
+
});
|
|
16
|
+
screenshots.$view.webContents.openDevTools();
|
|
17
|
+
electron_1.globalShortcut.register('ctrl+shift+a', () => {
|
|
18
|
+
screenshots.startCapture();
|
|
19
|
+
});
|
|
20
|
+
screenshots.on('windowCreated', ($win) => {
|
|
21
|
+
$win.on('focus', () => {
|
|
22
|
+
electron_1.globalShortcut.register('esc', () => {
|
|
23
|
+
if ($win === null || $win === void 0 ? void 0 : $win.isFocused()) {
|
|
24
|
+
screenshots.endCapture();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
$win.on('blur', () => {
|
|
29
|
+
electron_1.globalShortcut.unregister('esc');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
// 防止不能关闭截图界面
|
|
33
|
+
electron_1.globalShortcut.register('ctrl+shift+q', () => {
|
|
34
|
+
electron_1.app.quit();
|
|
35
|
+
});
|
|
36
|
+
// 点击确定按钮回调事件
|
|
37
|
+
screenshots.on('ok', (_event, buffer, bounds) => {
|
|
38
|
+
console.log('capture', buffer, bounds);
|
|
39
|
+
});
|
|
40
|
+
// 点击取消按钮回调事件
|
|
41
|
+
screenshots.on('cancel', () => {
|
|
42
|
+
console.log('capture', 'cancel1');
|
|
43
|
+
screenshots.setLang({
|
|
44
|
+
operation_ellipse_title: 'ellipse',
|
|
45
|
+
operation_rectangle_title: 'rectangle',
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
// 点击保存按钮回调事件
|
|
49
|
+
screenshots.on('save', (_event, buffer, bounds) => {
|
|
50
|
+
console.log('capture', buffer, bounds);
|
|
51
|
+
});
|
|
52
|
+
const mainWin = new electron_1.BrowserWindow({
|
|
53
|
+
show: true,
|
|
54
|
+
});
|
|
55
|
+
mainWin.removeMenu();
|
|
56
|
+
mainWin.loadURL('https://github.com/nashaofu');
|
|
57
|
+
});
|
|
58
|
+
electron_1.app.on('window-all-closed', () => {
|
|
59
|
+
if (process.platform !== 'darwin') {
|
|
60
|
+
electron_1.app.quit();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=demo.js.map
|
package/lib/demo.js.map
ADDED
|
@@ -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,EAA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G,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
ADDED
|
@@ -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
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Event {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.defaultPrevented = false;
|
|
6
|
+
}
|
|
7
|
+
preventDefault() {
|
|
8
|
+
this.defaultPrevented = true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.default = Event;
|
|
12
|
+
//# sourceMappingURL=event.js.map
|
package/lib/event.js.map
ADDED
|
@@ -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"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
+
// https://github.com/nashaofu/screenshots/issues/98
|
|
8
|
+
return {
|
|
9
|
+
id,
|
|
10
|
+
x: Math.floor(bounds.x),
|
|
11
|
+
y: Math.floor(bounds.y),
|
|
12
|
+
width: Math.floor(bounds.width),
|
|
13
|
+
height: Math.floor(bounds.height),
|
|
14
|
+
scaleFactor,
|
|
15
|
+
};
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.d.ts","sourceRoot":"","sources":["../src/index.cjs.ts"],"names":[],"mappings":""}
|
package/lib/index.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sourceRoot":"","sources":["../src/index.cjs.ts"],"names":[],"mappings":";;AAAA,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Events from 'node:events';
|
|
2
|
+
import { type Debugger } from 'debug';
|
|
3
|
+
import { BrowserView, BrowserWindow } from 'electron';
|
|
4
|
+
import type { Bounds } from './preload.js';
|
|
5
|
+
export type LoggerFn = (...args: unknown[]) => void;
|
|
6
|
+
export type Logger = Debugger | LoggerFn;
|
|
7
|
+
export interface Lang {
|
|
8
|
+
magnifier_position_label?: string;
|
|
9
|
+
operation_ok_title?: string;
|
|
10
|
+
operation_cancel_title?: string;
|
|
11
|
+
operation_save_title?: string;
|
|
12
|
+
operation_redo_title?: string;
|
|
13
|
+
operation_undo_title?: string;
|
|
14
|
+
operation_mosaic_title?: string;
|
|
15
|
+
operation_text_title?: string;
|
|
16
|
+
operation_brush_title?: string;
|
|
17
|
+
operation_arrow_title?: string;
|
|
18
|
+
operation_ellipse_title?: string;
|
|
19
|
+
operation_rectangle_title?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ScreenshotsOpts {
|
|
22
|
+
lang?: Lang;
|
|
23
|
+
logger?: Logger;
|
|
24
|
+
singleWindow?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type { Bounds };
|
|
27
|
+
export default class Screenshots extends Events {
|
|
28
|
+
$win: BrowserWindow | null;
|
|
29
|
+
$view: BrowserView;
|
|
30
|
+
private logger;
|
|
31
|
+
private singleWindow;
|
|
32
|
+
private isReady;
|
|
33
|
+
constructor(opts?: ScreenshotsOpts);
|
|
34
|
+
/**
|
|
35
|
+
* 开始截图
|
|
36
|
+
*/
|
|
37
|
+
startCapture(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* 结束截图
|
|
40
|
+
*/
|
|
41
|
+
endCapture(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* 设置语言
|
|
44
|
+
*/
|
|
45
|
+
setLang(lang: Partial<Lang>): Promise<void>;
|
|
46
|
+
private reset;
|
|
47
|
+
/**
|
|
48
|
+
* 初始化窗口
|
|
49
|
+
*/
|
|
50
|
+
private createWindow;
|
|
51
|
+
private capture;
|
|
52
|
+
/**
|
|
53
|
+
* 绑定ipc时间处理
|
|
54
|
+
*/
|
|
55
|
+
private listenIpc;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,aAAa,EAQd,MAAM,UAAU,CAAC;AAKlB,OAAO,KAAK,EAAE,MAAM,EAAmB,MAAM,cAAc,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AACpD,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEzC,MAAM,WAAW,IAAI;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sBAAsB,CAAC,EA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|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const node_events_1 = __importDefault(require("node:events"));
|
|
16
|
+
const debug_1 = __importDefault(require("debug"));
|
|
17
|
+
const electron_1 = require("electron");
|
|
18
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
19
|
+
const event_js_1 = __importDefault(require("./event.js"));
|
|
20
|
+
const getDisplay_js_1 = __importDefault(require("./getDisplay.js"));
|
|
21
|
+
const padStart_js_1 = __importDefault(require("./padStart.js"));
|
|
22
|
+
class Screenshots extends node_events_1.default {
|
|
23
|
+
constructor(opts) {
|
|
24
|
+
super();
|
|
25
|
+
// 截图窗口对象
|
|
26
|
+
this.$win = null;
|
|
27
|
+
this.$view = new electron_1.BrowserView({
|
|
28
|
+
webPreferences: {
|
|
29
|
+
preload: require.resolve('./preload.js'),
|
|
30
|
+
nodeIntegration: false,
|
|
31
|
+
contextIsolation: true,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
this.isReady = new Promise((resolve) => {
|
|
35
|
+
electron_1.ipcMain.once('SCREENSHOTS:ready', () => {
|
|
36
|
+
this.logger('SCREENSHOTS:ready');
|
|
37
|
+
resolve();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
this.logger = (opts === null || opts === void 0 ? void 0 : opts.logger) || (0, debug_1.default)('electron-screenshots');
|
|
41
|
+
this.singleWindow = (opts === null || opts === void 0 ? void 0 : opts.singleWindow) || false;
|
|
42
|
+
this.listenIpc();
|
|
43
|
+
this.$view.webContents.loadURL(`file://${require.resolve('react-screenshots/dist/electron.html')}`);
|
|
44
|
+
if (opts === null || opts === void 0 ? void 0 : opts.lang) {
|
|
45
|
+
this.setLang(opts.lang);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 开始截图
|
|
50
|
+
*/
|
|
51
|
+
startCapture() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
this.logger('startCapture');
|
|
54
|
+
const display = (0, getDisplay_js_1.default)();
|
|
55
|
+
const [imageUrl] = yield Promise.all([this.capture(display), this.isReady]);
|
|
56
|
+
yield this.createWindow(display);
|
|
57
|
+
this.$view.webContents.send('SCREENSHOTS:capture', display, imageUrl);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 结束截图
|
|
62
|
+
*/
|
|
63
|
+
endCapture() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
this.logger('endCapture');
|
|
66
|
+
yield this.reset();
|
|
67
|
+
if (!this.$win) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// 先清除 Kiosk 模式,然后取消全屏才有效
|
|
71
|
+
this.$win.setKiosk(false);
|
|
72
|
+
this.$win.blur();
|
|
73
|
+
this.$win.blurWebView();
|
|
74
|
+
this.$win.unmaximize();
|
|
75
|
+
this.$win.removeBrowserView(this.$view);
|
|
76
|
+
if (this.singleWindow) {
|
|
77
|
+
this.$win.hide();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.$win.destroy();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 设置语言
|
|
86
|
+
*/
|
|
87
|
+
setLang(lang) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
this.logger('setLang', lang);
|
|
90
|
+
yield this.isReady;
|
|
91
|
+
this.$view.webContents.send('SCREENSHOTS:setLang', lang);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
reset() {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
// 重置截图区域
|
|
97
|
+
this.$view.webContents.send('SCREENSHOTS:reset');
|
|
98
|
+
// 保证 UI 有足够的时间渲染
|
|
99
|
+
yield Promise.race([
|
|
100
|
+
new Promise((resolve) => {
|
|
101
|
+
setTimeout(() => resolve(), 500);
|
|
102
|
+
}),
|
|
103
|
+
new Promise((resolve) => {
|
|
104
|
+
electron_1.ipcMain.once('SCREENSHOTS:reset', () => resolve());
|
|
105
|
+
}),
|
|
106
|
+
]);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 初始化窗口
|
|
111
|
+
*/
|
|
112
|
+
createWindow(display) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
// 重置截图区域
|
|
116
|
+
yield this.reset();
|
|
117
|
+
// 复用未销毁的窗口
|
|
118
|
+
if (!this.$win || ((_b = (_a = this.$win) === null || _a === void 0 ? void 0 : _a.isDestroyed) === null || _b === void 0 ? void 0 : _b.call(_a))) {
|
|
119
|
+
const windowTypes = {
|
|
120
|
+
darwin: 'panel',
|
|
121
|
+
// linux 必须设置为 undefined,否则会在部分系统上不能触发focus 事件
|
|
122
|
+
// https://github.com/nashaofu/screenshots/issues/203#issuecomment-1518923486
|
|
123
|
+
linux: undefined,
|
|
124
|
+
win32: 'toolbar',
|
|
125
|
+
// openharmony 使用 panel 类型,与 darwin 类似
|
|
126
|
+
openharmony: 'panel',
|
|
127
|
+
};
|
|
128
|
+
this.$win = new electron_1.BrowserWindow({
|
|
129
|
+
title: 'screenshots',
|
|
130
|
+
x: display.x,
|
|
131
|
+
y: display.y,
|
|
132
|
+
width: display.width,
|
|
133
|
+
height: display.height,
|
|
134
|
+
useContentSize: true,
|
|
135
|
+
type: windowTypes[process.platform],
|
|
136
|
+
frame: false,
|
|
137
|
+
show: false,
|
|
138
|
+
autoHideMenuBar: true,
|
|
139
|
+
transparent: true,
|
|
140
|
+
resizable: false,
|
|
141
|
+
movable: false,
|
|
142
|
+
minimizable: false,
|
|
143
|
+
maximizable: false,
|
|
144
|
+
// focusable 必须设置为 true, 否则窗口不能及时响应esc按键,输入框也不能输入
|
|
145
|
+
focusable: true,
|
|
146
|
+
skipTaskbar: true,
|
|
147
|
+
alwaysOnTop: true,
|
|
148
|
+
/**
|
|
149
|
+
* linux 下必须设置为false,否则不能全屏显示在最上层
|
|
150
|
+
* mac 下设置为false,否则可能会导致程序坞不恢复问题,且与 kiosk 模式冲突
|
|
151
|
+
*/
|
|
152
|
+
fullscreen: false,
|
|
153
|
+
// mac fullscreenable 设置为 true 会导致应用崩溃
|
|
154
|
+
fullscreenable: false,
|
|
155
|
+
kiosk: true,
|
|
156
|
+
backgroundColor: '#00000000',
|
|
157
|
+
titleBarStyle: 'hidden',
|
|
158
|
+
hasShadow: false,
|
|
159
|
+
paintWhenInitiallyHidden: false,
|
|
160
|
+
// mac 特有的属性
|
|
161
|
+
roundedCorners: false,
|
|
162
|
+
enableLargerThanScreen: false,
|
|
163
|
+
acceptFirstMouse: true,
|
|
164
|
+
});
|
|
165
|
+
this.emit('windowCreated', this.$win);
|
|
166
|
+
this.$win.on('show', () => {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
(_a = this.$win) === null || _a === void 0 ? void 0 : _a.focus();
|
|
169
|
+
(_b = this.$win) === null || _b === void 0 ? void 0 : _b.setKiosk(true);
|
|
170
|
+
});
|
|
171
|
+
this.$win.on('closed', () => {
|
|
172
|
+
this.emit('windowClosed', this.$win);
|
|
173
|
+
this.$win = null;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
this.$win.setBrowserView(this.$view);
|
|
177
|
+
// 适定平台
|
|
178
|
+
if (process.platform === 'darwin' || process.platform === 'openharmony') {
|
|
179
|
+
this.$win.setWindowButtonVisibility(false);
|
|
180
|
+
}
|
|
181
|
+
if (process.platform !== 'win32' && process.platform !== 'openharmony') {
|
|
182
|
+
this.$win.setVisibleOnAllWorkspaces(true, {
|
|
183
|
+
visibleOnFullScreen: true,
|
|
184
|
+
skipTransformProcessType: true,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
this.$win.blur();
|
|
188
|
+
this.$win.setBounds(display);
|
|
189
|
+
this.$view.setBounds({
|
|
190
|
+
x: 0,
|
|
191
|
+
y: 0,
|
|
192
|
+
width: display.width,
|
|
193
|
+
height: display.height,
|
|
194
|
+
});
|
|
195
|
+
this.$win.setAlwaysOnTop(true);
|
|
196
|
+
this.$win.show();
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
capture(display) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
this.logger('SCREENSHOTS:capture');
|
|
202
|
+
try {
|
|
203
|
+
let Monitor;
|
|
204
|
+
try {
|
|
205
|
+
// OHOS: 使用 ohos-screenshots(OHOS 原生 API)
|
|
206
|
+
({ Monitor } = require('@ohos-ports/ohos-screenshots'));
|
|
207
|
+
} catch (e) {
|
|
208
|
+
// 其他平台: 使用原版 node-screenshots(X11/Win32/macOS)
|
|
209
|
+
({ Monitor } = yield import('node-screenshots'));
|
|
210
|
+
}
|
|
211
|
+
let point = {
|
|
212
|
+
x: display.x + display.width / 2,
|
|
213
|
+
y: display.y + display.height / 2,
|
|
214
|
+
};
|
|
215
|
+
if (process.platform === 'win32') {
|
|
216
|
+
point = electron_1.screen.screenToDipPoint(point);
|
|
217
|
+
}
|
|
218
|
+
const monitor = Monitor.fromPoint(point.x, point.y);
|
|
219
|
+
this.logger('SCREENSHOTS:capture Monitor.fromPoint arguments %o', display);
|
|
220
|
+
this.logger('SCREENSHOTS:capture Monitor.fromPoint return %o', {
|
|
221
|
+
id: monitor === null || monitor === void 0 ? void 0 : monitor.id,
|
|
222
|
+
name: monitor === null || monitor === void 0 ? void 0 : monitor.name,
|
|
223
|
+
x: monitor === null || monitor === void 0 ? void 0 : monitor.x,
|
|
224
|
+
y: monitor === null || monitor === void 0 ? void 0 : monitor.y,
|
|
225
|
+
width: monitor === null || monitor === void 0 ? void 0 : monitor.width,
|
|
226
|
+
height: monitor === null || monitor === void 0 ? void 0 : monitor.height,
|
|
227
|
+
rotation: monitor === null || monitor === void 0 ? void 0 : monitor.rotation,
|
|
228
|
+
scaleFactor: monitor === null || monitor === void 0 ? void 0 : monitor.scaleFactor,
|
|
229
|
+
frequency: monitor === null || monitor === void 0 ? void 0 : monitor.frequency,
|
|
230
|
+
isPrimary: monitor === null || monitor === void 0 ? void 0 : monitor.isPrimary,
|
|
231
|
+
});
|
|
232
|
+
if (!monitor) {
|
|
233
|
+
throw new Error(`Monitor.fromDisplay(${display.id}) get null`);
|
|
234
|
+
}
|
|
235
|
+
const image = yield monitor.captureImage();
|
|
236
|
+
const buffer = yield image.toPng(true);
|
|
237
|
+
return `data:image/png;base64,${buffer.toString('base64')}`;
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
this.logger('SCREENSHOTS:capture Monitor capture() error %o', err);
|
|
241
|
+
const sources = yield electron_1.desktopCapturer.getSources({
|
|
242
|
+
types: ['screen'],
|
|
243
|
+
thumbnailSize: {
|
|
244
|
+
width: Math.floor(display.width * display.scaleFactor),
|
|
245
|
+
height: Math.floor(display.height * display.scaleFactor),
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
let source;
|
|
249
|
+
// Linux系统上,screen.getDisplayNearestPoint 返回的 Display 对象的 id
|
|
250
|
+
// 和这里 source 对象上的 display_id(Linux上,这个值是空字符串) 或 id 的中间部分,都不一致
|
|
251
|
+
// 但是,如果只有一个显示器的话,其实不用判断,直接返回就行
|
|
252
|
+
if (sources.length === 1) {
|
|
253
|
+
[source] = sources;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
source = sources.find((item) => item.display_id === display.id.toString() ||
|
|
257
|
+
item.id.startsWith(`screen:${display.id}:`));
|
|
258
|
+
}
|
|
259
|
+
if (!source) {
|
|
260
|
+
this.logger("SCREENSHOTS:capture Can't find screen source. sources: %o, display: %o", sources, display);
|
|
261
|
+
throw new Error("Can't find screen source");
|
|
262
|
+
}
|
|
263
|
+
return source.thumbnail.toDataURL();
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 绑定ipc时间处理
|
|
269
|
+
*/
|
|
270
|
+
listenIpc() {
|
|
271
|
+
/**
|
|
272
|
+
* OK事件
|
|
273
|
+
*/
|
|
274
|
+
electron_1.ipcMain.on('SCREENSHOTS:ok', (_event, buffer, data) => {
|
|
275
|
+
this.logger('SCREENSHOTS:ok buffer.length %d, data: %o', buffer.length, data);
|
|
276
|
+
const event = new event_js_1.default();
|
|
277
|
+
this.emit('ok', event, buffer, data);
|
|
278
|
+
if (event.defaultPrevented) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
electron_1.clipboard.writeImage(electron_1.nativeImage.createFromBuffer(buffer));
|
|
282
|
+
this.endCapture();
|
|
283
|
+
});
|
|
284
|
+
/**
|
|
285
|
+
* CANCEL事件
|
|
286
|
+
*/
|
|
287
|
+
electron_1.ipcMain.on('SCREENSHOTS:cancel', () => {
|
|
288
|
+
this.logger('SCREENSHOTS:cancel');
|
|
289
|
+
const event = new event_js_1.default();
|
|
290
|
+
this.emit('cancel', event);
|
|
291
|
+
if (event.defaultPrevented) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
this.endCapture();
|
|
295
|
+
});
|
|
296
|
+
/**
|
|
297
|
+
* SAVE事件
|
|
298
|
+
*/
|
|
299
|
+
electron_1.ipcMain.on('SCREENSHOTS:save', (_event, buffer, data) => __awaiter(this, void 0, void 0, function* () {
|
|
300
|
+
this.logger('SCREENSHOTS:save buffer.length %d, data: %o', buffer.length, data);
|
|
301
|
+
const event = new event_js_1.default();
|
|
302
|
+
this.emit('save', event, buffer, data);
|
|
303
|
+
if (event.defaultPrevented || !this.$win) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const time = new Date();
|
|
307
|
+
const year = time.getFullYear();
|
|
308
|
+
const month = (0, padStart_js_1.default)(time.getMonth() + 1, 2, '0');
|
|
309
|
+
const date = (0, padStart_js_1.default)(time.getDate(), 2, '0');
|
|
310
|
+
const hours = (0, padStart_js_1.default)(time.getHours(), 2, '0');
|
|
311
|
+
const minutes = (0, padStart_js_1.default)(time.getMinutes(), 2, '0');
|
|
312
|
+
const seconds = (0, padStart_js_1.default)(time.getSeconds(), 2, '0');
|
|
313
|
+
const milliseconds = (0, padStart_js_1.default)(time.getMilliseconds(), 3, '0');
|
|
314
|
+
this.$win.setAlwaysOnTop(false);
|
|
315
|
+
const { canceled, filePath } = yield electron_1.dialog.showSaveDialog(this.$win, {
|
|
316
|
+
defaultPath: `${year}${month}${date}${hours}${minutes}${seconds}${milliseconds}.png`,
|
|
317
|
+
filters: [
|
|
318
|
+
{ name: 'Image (png)', extensions: ['png'] },
|
|
319
|
+
{ name: 'All Files', extensions: ['*'] },
|
|
320
|
+
],
|
|
321
|
+
});
|
|
322
|
+
if (!this.$win) {
|
|
323
|
+
this.emit('afterSave', new event_js_1.default(), buffer, data, false); // isSaved = false
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
this.$win.setAlwaysOnTop(true);
|
|
327
|
+
if (canceled || !filePath) {
|
|
328
|
+
this.emit('afterSave', new event_js_1.default(), buffer, data, false); // isSaved = false
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
yield fs_extra_1.default.writeFile(filePath, buffer);
|
|
332
|
+
this.emit('afterSave', new event_js_1.default(), buffer, data, true); // isSaved = true
|
|
333
|
+
this.endCapture();
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
exports.default = Screenshots;
|
|
338
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,kDAA6C;AAC7C,uCAUkB;AAClB,wDAA0B;AAC1B,0DAA+B;AAC/B,oEAA2D;AAC3D,gEAAqC;AA6BrC,MAAqB,WAAY,SAAQ,qBAAM;IAwB7C,YAAY,IAAsB;QAChC,KAAK,EAAE,CAAC;QAxBV,SAAS;QACF,SAAI,GAAyB,IAAI,CAAC;QAElC,UAAK,GAAgB,IAAI,sBAAW,CAAC;YAC1C,cAAc,EAAE;gBACd,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;gBACxC,eAAe,EAAE,KAAK;gBACtB,gBAAgB,EAAE,IAAI;aACvB;SACF,CAAC,CAAC;QAMK,YAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC9C,kBAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;gBACrC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;gBAEjC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAID,IAAI,CAAC,MAAM,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,KAAI,IAAA,eAAK,EAAC,sBAAsB,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,KAAI,KAAK,CAAC;QAChD,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAC5B,UAAU,OAAO,CAAC,OAAO,CAA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OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE;oBAC5C,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE;iBACzC;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,kBAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,kBAAkB;gBAC5E,OAAO;YACT,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,kBAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,kBAAkB;gBAC5E,OAAO;YACT,CAAC;YAED,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACrC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,kBAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,iBAAiB;YAC1E,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC,CAAA,CACF,CAAC;IACJ,CAAC;CACF;AA3WD,8BA2WC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 如果string字符串长度小于 length 则在左侧填充字符
|
|
3
|
+
* 如果超出length长度则截断超出的部分。
|
|
4
|
+
* @param {unknown} string
|
|
5
|
+
* @param {string} chars
|
|
6
|
+
* @param {number} length
|
|
7
|
+
*/
|
|
8
|
+
export default function padStart(string: unknown, length?: number, chars?: string): string;
|
|
9
|
+
//# sourceMappingURL=padStart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padStart.d.ts","sourceRoot":"","sources":["../src/padStart.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,OAAO,EACf,MAAM,SAAI,EACV,KAAK,SAAM,GACV,MAAM,CAMR"}
|
package/lib/padStart.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = padStart;
|
|
4
|
+
/**
|
|
5
|
+
* 如果string字符串长度小于 length 则在左侧填充字符
|
|
6
|
+
* 如果超出length长度则截断超出的部分。
|
|
7
|
+
* @param {unknown} string
|
|
8
|
+
* @param {string} chars
|
|
9
|
+
* @param {number} length
|
|
10
|
+
*/
|
|
11
|
+
function padStart(string, length = 0, chars = ' ') {
|
|
12
|
+
let str = String(string);
|
|
13
|
+
while (str.length < length) {
|
|
14
|
+
str = `${chars}${str}`;
|
|
15
|
+
}
|
|
16
|
+
return str;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=padStart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padStart.js","sourceRoot":"","sources":["../src/padStart.ts"],"names":[],"mappings":";;AAOA,2BAUC;AAjBD;;;;;;GAMG;AACH,SAAwB,QAAQ,CAC9B,MAAe,EACf,MAAM,GAAG,CAAC,EACV,KAAK,GAAG,GAAG;IAEX,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QAC3B,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/lib/preload.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Display } from './getDisplay.js';
|
|
2
|
+
export interface Bounds {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ScreenshotsData {
|
|
9
|
+
bounds: Bounds;
|
|
10
|
+
display: Display;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=preload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preload.d.ts","sourceRoot":"","sources":["../src/preload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
package/lib/preload.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
const electron_1 = require("electron");
|
|
5
|
+
const map = new Map();
|
|
6
|
+
electron_1.contextBridge.exposeInMainWorld('screenshots', {
|
|
7
|
+
ready: () => {
|
|
8
|
+
console.log('contextBridge ready');
|
|
9
|
+
electron_1.ipcRenderer.send('SCREENSHOTS:ready');
|
|
10
|
+
},
|
|
11
|
+
reset: () => {
|
|
12
|
+
console.log('contextBridge reset');
|
|
13
|
+
electron_1.ipcRenderer.send('SCREENSHOTS:reset');
|
|
14
|
+
},
|
|
15
|
+
save: (arrayBuffer, data) => {
|
|
16
|
+
console.log('contextBridge save', arrayBuffer, data);
|
|
17
|
+
electron_1.ipcRenderer.send('SCREENSHOTS:save', Buffer.from(arrayBuffer), data);
|
|
18
|
+
},
|
|
19
|
+
cancel: () => {
|
|
20
|
+
console.log('contextBridge cancel');
|
|
21
|
+
electron_1.ipcRenderer.send('SCREENSHOTS:cancel');
|
|
22
|
+
},
|
|
23
|
+
ok: (arrayBuffer, data) => {
|
|
24
|
+
console.log('contextBridge ok', arrayBuffer, data);
|
|
25
|
+
electron_1.ipcRenderer.send('SCREENSHOTS:ok', Buffer.from(arrayBuffer), data);
|
|
26
|
+
},
|
|
27
|
+
on: (channel, fn) => {
|
|
28
|
+
var _a;
|
|
29
|
+
console.log('contextBridge on', fn);
|
|
30
|
+
const listener = (_event, ...args) => {
|
|
31
|
+
console.log('contextBridge on', channel, fn, ...args);
|
|
32
|
+
fn(...args);
|
|
33
|
+
};
|
|
34
|
+
const listeners = (_a = map.get(fn)) !== null && _a !== void 0 ? _a : {};
|
|
35
|
+
listeners[channel] = listener;
|
|
36
|
+
map.set(fn, listeners);
|
|
37
|
+
electron_1.ipcRenderer.on(`SCREENSHOTS:${channel}`, listener);
|
|
38
|
+
},
|
|
39
|
+
off: (channel, fn) => {
|
|
40
|
+
var _a;
|
|
41
|
+
console.log('contextBridge off', fn);
|
|
42
|
+
const listeners = (_a = map.get(fn)) !== null && _a !== void 0 ? _a : {};
|
|
43
|
+
const listener = listeners[channel];
|
|
44
|
+
delete listeners[channel];
|
|
45
|
+
if (!listener) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
electron_1.ipcRenderer.off(`SCREENSHOTS:${channel}`, listener);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=preload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preload.js","sourceRoot":"","sources":["../src/preload.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,uCAA6E;AAqB7E,MAAM,GAAG,GAAG,IAAI,GAAG,EAA4D,CAAC;AAEhF,wBAAa,CAAC,iBAAiB,CAAC,aAAa,EAAE;IAC7C,KAAK,EAAE,GAAG,EAAE;QACV,OAAO,CAAC,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,SAAS,GAAG,MAAA,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,mCAAI,EAAE,CAAC;QACpC,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;QAC9B,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAEvB,sBAAW,CAAC,EAAE,CAAC,eAAe,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,GAAG,EAAE,CAAC,OAAe,EAAE,EAAuB,EAAE,EAAE;;QAChD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAErC,MAAM,SAAS,GAAG,MAAA,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,mCAAI,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QACpC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;QAE1B,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO;QACT,CAAC;QAED,sBAAW,CAAC,GAAG,CAAC,eAAe,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ohos-ports/electron-screenshots",
|
|
3
|
+
"version": "0.6.2-beta.1",
|
|
4
|
+
"description": "electron 截图插件",
|
|
5
|
+
"types": "lib/index.d.ts",
|
|
6
|
+
"main": "lib/index.cjs.js",
|
|
7
|
+
"module": "lib/index.js",
|
|
8
|
+
"type": "commonjs",
|
|
9
|
+
"files": [
|
|
10
|
+
"lib/**"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/nashaofu/screenshots.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"electron",
|
|
18
|
+
"shortcut",
|
|
19
|
+
"screenshot",
|
|
20
|
+
"cropper"
|
|
21
|
+
],
|
|
22
|
+
"author": "nashaofu",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/nashaofu/screenshots/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/nashaofu/screenshots/tree/master/packages/electron-screenshots#readme",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"registry": "https://registry.npmjs.org/",
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"debug": "^4.4.3",
|
|
34
|
+
"fs-extra": "^11.3.3",
|
|
35
|
+
"node-screenshots": "^0.2.8",
|
|
36
|
+
"ohos-screenshots": "npm:@ohos-ports/ohos-screenshots@^1.0.0-beta.1",
|
|
37
|
+
"react-screenshots": "0.6.1"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"electron": ">=20"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/debug": "^4.1.12",
|
|
44
|
+
"@types/fs-extra": "^11.0.4",
|
|
45
|
+
"@types/node": "^25.2.1",
|
|
46
|
+
"cross-env": "^10.1.0",
|
|
47
|
+
"electron": "^39.8.4",
|
|
48
|
+
"rimraf": "^6.1.2",
|
|
49
|
+
"typescript": "^5.9.3"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"start": "cross-env DEBUG=electron-screenshots electron lib/demo.js",
|
|
53
|
+
"dev": "tsc --sourceMap --watch",
|
|
54
|
+
"build": "npm run clean && tsc",
|
|
55
|
+
"clean": "rimraf lib"
|
|
56
|
+
}
|
|
57
|
+
}
|