electron-snapora 1.0.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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.es.md +79 -0
- package/README.ja.md +79 -0
- package/README.ko.md +79 -0
- package/README.md +392 -0
- package/README.zh-CN.md +79 -0
- package/dist/core/index.cjs +184 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +97 -0
- package/dist/core/index.d.ts +97 -0
- package/dist/core/index.mjs +150 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/main/index.cjs +1637 -0
- package/dist/main/index.cjs.map +1 -0
- package/dist/main/index.d.cts +283 -0
- package/dist/main/index.d.ts +283 -0
- package/dist/main/index.mjs +1599 -0
- package/dist/main/index.mjs.map +1 -0
- package/dist/messages-DYY0MpGh.d.ts +76 -0
- package/dist/messages-ifub9bae.d.cts +76 -0
- package/dist/overlay/assets/index-7dVRGn83.css +1 -0
- package/dist/overlay/assets/index-CJf5iC1U.js +2 -0
- package/dist/overlay/assets/index-CJf5iC1U.js.map +1 -0
- package/dist/overlay/index.html +316 -0
- package/dist/overlay/preload.cjs +97 -0
- package/dist/overlay/preload.cjs.map +1 -0
- package/dist/overlay/preload.d.cts +16 -0
- package/dist/overlay/preload.d.ts +16 -0
- package/dist/overlay/preload.mjs +80 -0
- package/dist/overlay/preload.mjs.map +1 -0
- package/dist/preload/auto.cjs +24 -0
- package/dist/preload/auto.cjs.map +1 -0
- package/dist/preload/auto.d.cts +2 -0
- package/dist/preload/auto.d.ts +2 -0
- package/dist/preload/auto.mjs +22 -0
- package/dist/preload/auto.mjs.map +1 -0
- package/dist/preload/index.cjs +46 -0
- package/dist/preload/index.cjs.map +1 -0
- package/dist/preload/index.d.cts +18 -0
- package/dist/preload/index.d.ts +18 -0
- package/dist/preload/index.mjs +19 -0
- package/dist/preload/index.mjs.map +1 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +92 -0
- package/dist/types/index.d.ts +92 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/package.json +158 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/preload.ts
|
|
21
|
+
var preload_exports = {};
|
|
22
|
+
__export(preload_exports, {
|
|
23
|
+
exposeScreenshotApi: () => exposeScreenshotApi
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(preload_exports);
|
|
26
|
+
|
|
27
|
+
// src/electron/protocol/channels.ts
|
|
28
|
+
var DEFAULT_HOST_CAPTURE_CHANNEL = "electron-snapora:host:capture";
|
|
29
|
+
var DEFAULT_HOST_CANCEL_CHANNEL = "electron-snapora:host:cancel";
|
|
30
|
+
|
|
31
|
+
// src/electron/preload/host-preload.ts
|
|
32
|
+
function exposeScreenshotApi(options) {
|
|
33
|
+
const channel = options.channel ?? DEFAULT_HOST_CAPTURE_CHANNEL;
|
|
34
|
+
const cancelChannel = options.cancelChannel ?? (options.channel ? `${options.channel}:cancel` : DEFAULT_HOST_CANCEL_CHANNEL);
|
|
35
|
+
const api = {
|
|
36
|
+
capture: (captureOptions) => options.ipcRenderer.invoke(channel, captureOptions),
|
|
37
|
+
cancel: () => options.ipcRenderer.invoke(cancelChannel)
|
|
38
|
+
};
|
|
39
|
+
options.contextBridge.exposeInMainWorld(options.globalName ?? "electronSnapora", api);
|
|
40
|
+
return api;
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
exposeScreenshotApi
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/preload.ts","../../src/electron/protocol/channels.ts","../../src/electron/preload/host-preload.ts"],"sourcesContent":["export {\n exposeScreenshotApi,\n type ExposeScreenshotApiOptions,\n} from './electron/preload/host-preload.js';\nexport type {\n ScreenshotImageResult,\n ScreenshotOptions,\n ScreenshotOutputMetadata,\n ScreenshotRendererApi,\n ScreenshotResult,\n} from './types.js';\n","export const DEFAULT_HOST_CAPTURE_CHANNEL = 'electron-snapora:host:capture';\nexport const DEFAULT_HOST_CANCEL_CHANNEL = 'electron-snapora:host:cancel';\n\nexport const OVERLAY_CHANNELS = {\n ready: 'electron-snapora:overlay:ready',\n prepared: 'electron-snapora:overlay:prepared',\n initialize: 'electron-snapora:overlay:initialize',\n feedback: 'electron-snapora:overlay:feedback',\n feedbackReady: 'electron-snapora:overlay:feedback-ready',\n confirm: 'electron-snapora:overlay:confirm',\n cancel: 'electron-snapora:overlay:cancel',\n error: 'electron-snapora:overlay:error',\n output: 'electron-snapora:overlay:output',\n} as const;\n","import type { ContextBridge, IpcRenderer } from 'electron';\n\nimport type {\n ScreenshotOptions,\n ScreenshotRendererApi,\n ScreenshotResult,\n} from '../../types.js';\nimport {\n DEFAULT_HOST_CANCEL_CHANNEL,\n DEFAULT_HOST_CAPTURE_CHANNEL,\n} from '../protocol/channels.js';\n\nexport interface ExposeScreenshotApiOptions {\n contextBridge: ContextBridge;\n ipcRenderer: IpcRenderer;\n globalName?: string;\n channel?: string;\n cancelChannel?: string;\n}\n\n/**\n * 将最小截图接口暴露给宿主页面。调用方显式传入 Electron 能力,\n * 使包本身不依赖 remote,也不要求关闭 contextIsolation。\n */\nexport function exposeScreenshotApi(\n options: ExposeScreenshotApiOptions\n): ScreenshotRendererApi {\n const channel = options.channel ?? DEFAULT_HOST_CAPTURE_CHANNEL;\n const cancelChannel =\n options.cancelChannel ??\n (options.channel ? `${options.channel}:cancel` : DEFAULT_HOST_CANCEL_CHANNEL);\n const api: ScreenshotRendererApi = {\n capture: (captureOptions?: ScreenshotOptions) =>\n options.ipcRenderer.invoke(channel, captureOptions) as Promise<ScreenshotResult>,\n cancel: () => options.ipcRenderer.invoke(cancelChannel) as Promise<boolean>,\n };\n\n options.contextBridge.exposeInMainWorld(options.globalName ?? 'electronSnapora', api);\n return api;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,+BAA+B;AACrC,IAAM,8BAA8B;;;ACuBpC,SAAS,oBACd,SACuB;AACvB,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,gBACJ,QAAQ,kBACP,QAAQ,UAAU,GAAG,QAAQ,OAAO,YAAY;AACnD,QAAM,MAA6B;AAAA,IACjC,SAAS,CAAC,mBACR,QAAQ,YAAY,OAAO,SAAS,cAAc;AAAA,IACpD,QAAQ,MAAM,QAAQ,YAAY,OAAO,aAAa;AAAA,EACxD;AAEA,UAAQ,cAAc,kBAAkB,QAAQ,cAAc,mBAAmB,GAAG;AACpF,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ContextBridge, IpcRenderer } from 'electron';
|
|
2
|
+
import { ScreenshotRendererApi } from '../types/index.cjs';
|
|
3
|
+
export { ScreenshotImageResult, ScreenshotOptions, ScreenshotOutputMetadata, ScreenshotResult } from '../types/index.cjs';
|
|
4
|
+
|
|
5
|
+
interface ExposeScreenshotApiOptions {
|
|
6
|
+
contextBridge: ContextBridge;
|
|
7
|
+
ipcRenderer: IpcRenderer;
|
|
8
|
+
globalName?: string;
|
|
9
|
+
channel?: string;
|
|
10
|
+
cancelChannel?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 将最小截图接口暴露给宿主页面。调用方显式传入 Electron 能力,
|
|
14
|
+
* 使包本身不依赖 remote,也不要求关闭 contextIsolation。
|
|
15
|
+
*/
|
|
16
|
+
declare function exposeScreenshotApi(options: ExposeScreenshotApiOptions): ScreenshotRendererApi;
|
|
17
|
+
|
|
18
|
+
export { type ExposeScreenshotApiOptions, ScreenshotRendererApi, exposeScreenshotApi };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ContextBridge, IpcRenderer } from 'electron';
|
|
2
|
+
import { ScreenshotRendererApi } from '../types/index.js';
|
|
3
|
+
export { ScreenshotImageResult, ScreenshotOptions, ScreenshotOutputMetadata, ScreenshotResult } from '../types/index.js';
|
|
4
|
+
|
|
5
|
+
interface ExposeScreenshotApiOptions {
|
|
6
|
+
contextBridge: ContextBridge;
|
|
7
|
+
ipcRenderer: IpcRenderer;
|
|
8
|
+
globalName?: string;
|
|
9
|
+
channel?: string;
|
|
10
|
+
cancelChannel?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 将最小截图接口暴露给宿主页面。调用方显式传入 Electron 能力,
|
|
14
|
+
* 使包本身不依赖 remote,也不要求关闭 contextIsolation。
|
|
15
|
+
*/
|
|
16
|
+
declare function exposeScreenshotApi(options: ExposeScreenshotApiOptions): ScreenshotRendererApi;
|
|
17
|
+
|
|
18
|
+
export { type ExposeScreenshotApiOptions, ScreenshotRendererApi, exposeScreenshotApi };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/electron/protocol/channels.ts
|
|
2
|
+
var DEFAULT_HOST_CAPTURE_CHANNEL = "electron-snapora:host:capture";
|
|
3
|
+
var DEFAULT_HOST_CANCEL_CHANNEL = "electron-snapora:host:cancel";
|
|
4
|
+
|
|
5
|
+
// src/electron/preload/host-preload.ts
|
|
6
|
+
function exposeScreenshotApi(options) {
|
|
7
|
+
const channel = options.channel ?? DEFAULT_HOST_CAPTURE_CHANNEL;
|
|
8
|
+
const cancelChannel = options.cancelChannel ?? (options.channel ? `${options.channel}:cancel` : DEFAULT_HOST_CANCEL_CHANNEL);
|
|
9
|
+
const api = {
|
|
10
|
+
capture: (captureOptions) => options.ipcRenderer.invoke(channel, captureOptions),
|
|
11
|
+
cancel: () => options.ipcRenderer.invoke(cancelChannel)
|
|
12
|
+
};
|
|
13
|
+
options.contextBridge.exposeInMainWorld(options.globalName ?? "electronSnapora", api);
|
|
14
|
+
return api;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
exposeScreenshotApi
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/electron/protocol/channels.ts","../../src/electron/preload/host-preload.ts"],"sourcesContent":["export const DEFAULT_HOST_CAPTURE_CHANNEL = 'electron-snapora:host:capture';\nexport const DEFAULT_HOST_CANCEL_CHANNEL = 'electron-snapora:host:cancel';\n\nexport const OVERLAY_CHANNELS = {\n ready: 'electron-snapora:overlay:ready',\n prepared: 'electron-snapora:overlay:prepared',\n initialize: 'electron-snapora:overlay:initialize',\n feedback: 'electron-snapora:overlay:feedback',\n feedbackReady: 'electron-snapora:overlay:feedback-ready',\n confirm: 'electron-snapora:overlay:confirm',\n cancel: 'electron-snapora:overlay:cancel',\n error: 'electron-snapora:overlay:error',\n output: 'electron-snapora:overlay:output',\n} as const;\n","import type { ContextBridge, IpcRenderer } from 'electron';\n\nimport type {\n ScreenshotOptions,\n ScreenshotRendererApi,\n ScreenshotResult,\n} from '../../types.js';\nimport {\n DEFAULT_HOST_CANCEL_CHANNEL,\n DEFAULT_HOST_CAPTURE_CHANNEL,\n} from '../protocol/channels.js';\n\nexport interface ExposeScreenshotApiOptions {\n contextBridge: ContextBridge;\n ipcRenderer: IpcRenderer;\n globalName?: string;\n channel?: string;\n cancelChannel?: string;\n}\n\n/**\n * 将最小截图接口暴露给宿主页面。调用方显式传入 Electron 能力,\n * 使包本身不依赖 remote,也不要求关闭 contextIsolation。\n */\nexport function exposeScreenshotApi(\n options: ExposeScreenshotApiOptions\n): ScreenshotRendererApi {\n const channel = options.channel ?? DEFAULT_HOST_CAPTURE_CHANNEL;\n const cancelChannel =\n options.cancelChannel ??\n (options.channel ? `${options.channel}:cancel` : DEFAULT_HOST_CANCEL_CHANNEL);\n const api: ScreenshotRendererApi = {\n capture: (captureOptions?: ScreenshotOptions) =>\n options.ipcRenderer.invoke(channel, captureOptions) as Promise<ScreenshotResult>,\n cancel: () => options.ipcRenderer.invoke(cancelChannel) as Promise<boolean>,\n };\n\n options.contextBridge.exposeInMainWorld(options.globalName ?? 'electronSnapora', api);\n return api;\n}\n"],"mappings":";AAAO,IAAM,+BAA+B;AACrC,IAAM,8BAA8B;;;ACuBpC,SAAS,oBACd,SACuB;AACvB,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,gBACJ,QAAQ,kBACP,QAAQ,UAAU,GAAG,QAAQ,OAAO,YAAY;AACnD,QAAM,MAA6B;AAAA,IACjC,SAAS,CAAC,mBACR,QAAQ,YAAY,OAAO,SAAS,cAAc;AAAA,IACpD,QAAQ,MAAM,QAAQ,YAAY,OAAO,aAAa;AAAA,EACxD;AAEA,UAAQ,cAAc,kBAAkB,QAAQ,cAAc,mBAAmB,GAAG;AACpF,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export type ScreenshotTool =\n 'rectangle' | 'ellipse' | 'arrow' | 'brush' | 'text' | 'mosaic';\n\nexport interface ScreenshotBounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport type ScreenshotLocale = 'zh-CN' | 'en-US';\n\nexport interface ScreenshotMessages {\n preparing: string;\n instruction: string;\n exporting: string;\n copied: string;\n saveCancelled: string;\n cancel: string;\n save: string;\n confirm: string;\n select: string;\n rectangle: string;\n ellipse: string;\n arrow: string;\n brush: string;\n text: string;\n mosaic: string;\n undo: string;\n redo: string;\n color: string;\n lineWidth: string;\n fontSize: string;\n annotationCanvas: string;\n selection: string;\n actions: string;\n annotationTools: string;\n history: string;\n annotationStyle: string;\n outputActions: string;\n annotationText: string;\n}\n\nexport type ScreenshotMessageOverrides = Partial<ScreenshotMessages>;\n\nexport interface ScreenshotTheme {\n mode?: 'dark' | 'light';\n accentColor?: string;\n accentForegroundColor?: string;\n maskColor?: string;\n toolbarBackground?: string;\n toolbarForeground?: string;\n toolbarBorderColor?: string;\n toolbarHoverBackground?: string;\n tooltipBackground?: string;\n tooltipForeground?: string;\n destructiveColor?: string;\n warningColor?: string;\n warningForegroundColor?: string;\n selectionHandleColor?: string;\n}\n\nexport interface ScreenshotOptions {\n display?: 'cursor' | 'primary' | string;\n tools?: ScreenshotTool[];\n defaultTool?: 'select' | ScreenshotTool;\n locale?: ScreenshotLocale;\n messages?: ScreenshotMessageOverrides;\n theme?: ScreenshotTheme;\n}\n\nexport type ScreenshotErrorCode =\n | 'CAPTURE_BUSY'\n | 'INVALID_REQUEST'\n | 'RESOURCE_LIMIT_EXCEEDED'\n | 'PERMISSION_DENIED'\n | 'DISPLAY_NOT_FOUND'\n | 'CAPTURE_FAILED'\n | 'OVERLAY_LOAD_FAILED'\n | 'EXPORT_FAILED'\n | 'INVALID_RESULT'\n | 'UNSUPPORTED_PLATFORM';\n\nexport interface ScreenshotImageResult {\n status: 'completed';\n data: Uint8Array;\n mimeType: 'image/png';\n bounds: ScreenshotBounds;\n displayId: string;\n}\n\nexport type ScreenshotOutputMetadata =\n { action: 'copy' } | { action: 'save'; filePath: string };\n\nexport type ScreenshotResult =\n | (ScreenshotImageResult & { output: ScreenshotOutputMetadata })\n | {\n status: 'cancelled';\n }\n | {\n status: 'failed';\n code: ScreenshotErrorCode;\n message: string;\n };\n\nexport interface ScreenshotRendererApi {\n capture(options?: ScreenshotOptions): Promise<ScreenshotResult>;\n cancel(): Promise<boolean>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
type ScreenshotTool = 'rectangle' | 'ellipse' | 'arrow' | 'brush' | 'text' | 'mosaic';
|
|
2
|
+
interface ScreenshotBounds {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
type ScreenshotLocale = 'zh-CN' | 'en-US';
|
|
9
|
+
interface ScreenshotMessages {
|
|
10
|
+
preparing: string;
|
|
11
|
+
instruction: string;
|
|
12
|
+
exporting: string;
|
|
13
|
+
copied: string;
|
|
14
|
+
saveCancelled: string;
|
|
15
|
+
cancel: string;
|
|
16
|
+
save: string;
|
|
17
|
+
confirm: string;
|
|
18
|
+
select: string;
|
|
19
|
+
rectangle: string;
|
|
20
|
+
ellipse: string;
|
|
21
|
+
arrow: string;
|
|
22
|
+
brush: string;
|
|
23
|
+
text: string;
|
|
24
|
+
mosaic: string;
|
|
25
|
+
undo: string;
|
|
26
|
+
redo: string;
|
|
27
|
+
color: string;
|
|
28
|
+
lineWidth: string;
|
|
29
|
+
fontSize: string;
|
|
30
|
+
annotationCanvas: string;
|
|
31
|
+
selection: string;
|
|
32
|
+
actions: string;
|
|
33
|
+
annotationTools: string;
|
|
34
|
+
history: string;
|
|
35
|
+
annotationStyle: string;
|
|
36
|
+
outputActions: string;
|
|
37
|
+
annotationText: string;
|
|
38
|
+
}
|
|
39
|
+
type ScreenshotMessageOverrides = Partial<ScreenshotMessages>;
|
|
40
|
+
interface ScreenshotTheme {
|
|
41
|
+
mode?: 'dark' | 'light';
|
|
42
|
+
accentColor?: string;
|
|
43
|
+
accentForegroundColor?: string;
|
|
44
|
+
maskColor?: string;
|
|
45
|
+
toolbarBackground?: string;
|
|
46
|
+
toolbarForeground?: string;
|
|
47
|
+
toolbarBorderColor?: string;
|
|
48
|
+
toolbarHoverBackground?: string;
|
|
49
|
+
tooltipBackground?: string;
|
|
50
|
+
tooltipForeground?: string;
|
|
51
|
+
destructiveColor?: string;
|
|
52
|
+
warningColor?: string;
|
|
53
|
+
warningForegroundColor?: string;
|
|
54
|
+
selectionHandleColor?: string;
|
|
55
|
+
}
|
|
56
|
+
interface ScreenshotOptions {
|
|
57
|
+
display?: 'cursor' | 'primary' | string;
|
|
58
|
+
tools?: ScreenshotTool[];
|
|
59
|
+
defaultTool?: 'select' | ScreenshotTool;
|
|
60
|
+
locale?: ScreenshotLocale;
|
|
61
|
+
messages?: ScreenshotMessageOverrides;
|
|
62
|
+
theme?: ScreenshotTheme;
|
|
63
|
+
}
|
|
64
|
+
type ScreenshotErrorCode = 'CAPTURE_BUSY' | 'INVALID_REQUEST' | 'RESOURCE_LIMIT_EXCEEDED' | 'PERMISSION_DENIED' | 'DISPLAY_NOT_FOUND' | 'CAPTURE_FAILED' | 'OVERLAY_LOAD_FAILED' | 'EXPORT_FAILED' | 'INVALID_RESULT' | 'UNSUPPORTED_PLATFORM';
|
|
65
|
+
interface ScreenshotImageResult {
|
|
66
|
+
status: 'completed';
|
|
67
|
+
data: Uint8Array;
|
|
68
|
+
mimeType: 'image/png';
|
|
69
|
+
bounds: ScreenshotBounds;
|
|
70
|
+
displayId: string;
|
|
71
|
+
}
|
|
72
|
+
type ScreenshotOutputMetadata = {
|
|
73
|
+
action: 'copy';
|
|
74
|
+
} | {
|
|
75
|
+
action: 'save';
|
|
76
|
+
filePath: string;
|
|
77
|
+
};
|
|
78
|
+
type ScreenshotResult = (ScreenshotImageResult & {
|
|
79
|
+
output: ScreenshotOutputMetadata;
|
|
80
|
+
}) | {
|
|
81
|
+
status: 'cancelled';
|
|
82
|
+
} | {
|
|
83
|
+
status: 'failed';
|
|
84
|
+
code: ScreenshotErrorCode;
|
|
85
|
+
message: string;
|
|
86
|
+
};
|
|
87
|
+
interface ScreenshotRendererApi {
|
|
88
|
+
capture(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
89
|
+
cancel(): Promise<boolean>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type { ScreenshotBounds, ScreenshotErrorCode, ScreenshotImageResult, ScreenshotLocale, ScreenshotMessageOverrides, ScreenshotMessages, ScreenshotOptions, ScreenshotOutputMetadata, ScreenshotRendererApi, ScreenshotResult, ScreenshotTheme, ScreenshotTool };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
type ScreenshotTool = 'rectangle' | 'ellipse' | 'arrow' | 'brush' | 'text' | 'mosaic';
|
|
2
|
+
interface ScreenshotBounds {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
type ScreenshotLocale = 'zh-CN' | 'en-US';
|
|
9
|
+
interface ScreenshotMessages {
|
|
10
|
+
preparing: string;
|
|
11
|
+
instruction: string;
|
|
12
|
+
exporting: string;
|
|
13
|
+
copied: string;
|
|
14
|
+
saveCancelled: string;
|
|
15
|
+
cancel: string;
|
|
16
|
+
save: string;
|
|
17
|
+
confirm: string;
|
|
18
|
+
select: string;
|
|
19
|
+
rectangle: string;
|
|
20
|
+
ellipse: string;
|
|
21
|
+
arrow: string;
|
|
22
|
+
brush: string;
|
|
23
|
+
text: string;
|
|
24
|
+
mosaic: string;
|
|
25
|
+
undo: string;
|
|
26
|
+
redo: string;
|
|
27
|
+
color: string;
|
|
28
|
+
lineWidth: string;
|
|
29
|
+
fontSize: string;
|
|
30
|
+
annotationCanvas: string;
|
|
31
|
+
selection: string;
|
|
32
|
+
actions: string;
|
|
33
|
+
annotationTools: string;
|
|
34
|
+
history: string;
|
|
35
|
+
annotationStyle: string;
|
|
36
|
+
outputActions: string;
|
|
37
|
+
annotationText: string;
|
|
38
|
+
}
|
|
39
|
+
type ScreenshotMessageOverrides = Partial<ScreenshotMessages>;
|
|
40
|
+
interface ScreenshotTheme {
|
|
41
|
+
mode?: 'dark' | 'light';
|
|
42
|
+
accentColor?: string;
|
|
43
|
+
accentForegroundColor?: string;
|
|
44
|
+
maskColor?: string;
|
|
45
|
+
toolbarBackground?: string;
|
|
46
|
+
toolbarForeground?: string;
|
|
47
|
+
toolbarBorderColor?: string;
|
|
48
|
+
toolbarHoverBackground?: string;
|
|
49
|
+
tooltipBackground?: string;
|
|
50
|
+
tooltipForeground?: string;
|
|
51
|
+
destructiveColor?: string;
|
|
52
|
+
warningColor?: string;
|
|
53
|
+
warningForegroundColor?: string;
|
|
54
|
+
selectionHandleColor?: string;
|
|
55
|
+
}
|
|
56
|
+
interface ScreenshotOptions {
|
|
57
|
+
display?: 'cursor' | 'primary' | string;
|
|
58
|
+
tools?: ScreenshotTool[];
|
|
59
|
+
defaultTool?: 'select' | ScreenshotTool;
|
|
60
|
+
locale?: ScreenshotLocale;
|
|
61
|
+
messages?: ScreenshotMessageOverrides;
|
|
62
|
+
theme?: ScreenshotTheme;
|
|
63
|
+
}
|
|
64
|
+
type ScreenshotErrorCode = 'CAPTURE_BUSY' | 'INVALID_REQUEST' | 'RESOURCE_LIMIT_EXCEEDED' | 'PERMISSION_DENIED' | 'DISPLAY_NOT_FOUND' | 'CAPTURE_FAILED' | 'OVERLAY_LOAD_FAILED' | 'EXPORT_FAILED' | 'INVALID_RESULT' | 'UNSUPPORTED_PLATFORM';
|
|
65
|
+
interface ScreenshotImageResult {
|
|
66
|
+
status: 'completed';
|
|
67
|
+
data: Uint8Array;
|
|
68
|
+
mimeType: 'image/png';
|
|
69
|
+
bounds: ScreenshotBounds;
|
|
70
|
+
displayId: string;
|
|
71
|
+
}
|
|
72
|
+
type ScreenshotOutputMetadata = {
|
|
73
|
+
action: 'copy';
|
|
74
|
+
} | {
|
|
75
|
+
action: 'save';
|
|
76
|
+
filePath: string;
|
|
77
|
+
};
|
|
78
|
+
type ScreenshotResult = (ScreenshotImageResult & {
|
|
79
|
+
output: ScreenshotOutputMetadata;
|
|
80
|
+
}) | {
|
|
81
|
+
status: 'cancelled';
|
|
82
|
+
} | {
|
|
83
|
+
status: 'failed';
|
|
84
|
+
code: ScreenshotErrorCode;
|
|
85
|
+
message: string;
|
|
86
|
+
};
|
|
87
|
+
interface ScreenshotRendererApi {
|
|
88
|
+
capture(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
89
|
+
cancel(): Promise<boolean>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type { ScreenshotBounds, ScreenshotErrorCode, ScreenshotImageResult, ScreenshotLocale, ScreenshotMessageOverrides, ScreenshotMessages, ScreenshotOptions, ScreenshotOutputMetadata, ScreenshotRendererApi, ScreenshotResult, ScreenshotTheme, ScreenshotTool };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "electron-snapora",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Electron screenshot and annotation toolkit for region capture, editing, clipboard copy, and PNG export.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"electron",
|
|
8
|
+
"electron-screenshot",
|
|
9
|
+
"electron-plugin",
|
|
10
|
+
"screenshot",
|
|
11
|
+
"screenshot-tool",
|
|
12
|
+
"screenshot-editor",
|
|
13
|
+
"screen-capture",
|
|
14
|
+
"desktop-capture",
|
|
15
|
+
"region-capture",
|
|
16
|
+
"snipping-tool",
|
|
17
|
+
"annotation",
|
|
18
|
+
"image-annotation",
|
|
19
|
+
"png"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/electron-tools/electron-snapora.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/electron-tools/electron-snapora/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/electron-tools/electron-snapora#readme",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"tag": "latest"
|
|
33
|
+
},
|
|
34
|
+
"type": "module",
|
|
35
|
+
"main": "./dist/main/index.cjs",
|
|
36
|
+
"module": "./dist/main/index.mjs",
|
|
37
|
+
"types": "./dist/main/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"CHANGELOG.md",
|
|
41
|
+
"LICENSE",
|
|
42
|
+
"README*.md"
|
|
43
|
+
],
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/main/index.d.ts",
|
|
48
|
+
"default": "./dist/main/index.mjs"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./dist/main/index.d.cts",
|
|
52
|
+
"default": "./dist/main/index.cjs"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"./main": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./dist/main/index.d.ts",
|
|
58
|
+
"default": "./dist/main/index.mjs"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./dist/main/index.d.cts",
|
|
62
|
+
"default": "./dist/main/index.cjs"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"./preload": {
|
|
66
|
+
"import": {
|
|
67
|
+
"types": "./dist/preload/index.d.ts",
|
|
68
|
+
"default": "./dist/preload/index.mjs"
|
|
69
|
+
},
|
|
70
|
+
"require": {
|
|
71
|
+
"types": "./dist/preload/index.d.cts",
|
|
72
|
+
"default": "./dist/preload/index.cjs"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"./preload/auto": {
|
|
76
|
+
"types": "./dist/preload/auto.d.cts",
|
|
77
|
+
"require": "./dist/preload/auto.cjs",
|
|
78
|
+
"default": "./dist/preload/auto.cjs"
|
|
79
|
+
},
|
|
80
|
+
"./core": {
|
|
81
|
+
"import": {
|
|
82
|
+
"types": "./dist/core/index.d.ts",
|
|
83
|
+
"default": "./dist/core/index.mjs"
|
|
84
|
+
},
|
|
85
|
+
"require": {
|
|
86
|
+
"types": "./dist/core/index.d.cts",
|
|
87
|
+
"default": "./dist/core/index.cjs"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"./types": {
|
|
91
|
+
"import": {
|
|
92
|
+
"types": "./dist/types/index.d.ts",
|
|
93
|
+
"default": "./dist/types/index.mjs"
|
|
94
|
+
},
|
|
95
|
+
"require": {
|
|
96
|
+
"types": "./dist/types/index.d.cts",
|
|
97
|
+
"default": "./dist/types/index.cjs"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"scripts": {
|
|
102
|
+
"clean": "rimraf dist coverage",
|
|
103
|
+
"dev": "vite --config vite.config.ts",
|
|
104
|
+
"demo": "pnpm run build && electron demo/main.cjs",
|
|
105
|
+
"demo:host-smoke": "pnpm run build && electron demo/host-smoke.cjs",
|
|
106
|
+
"demo:selection-smoke": "pnpm run build && electron demo/selection-smoke.cjs",
|
|
107
|
+
"demo:double-click-smoke": "pnpm run build && electron demo/selection-smoke.cjs --double-click",
|
|
108
|
+
"demo:tools-smoke": "pnpm run build && electron demo/tools-smoke.cjs",
|
|
109
|
+
"demo:stress-4k": "pnpm run build && electron demo/stress-4k.cjs",
|
|
110
|
+
"demo:copy-smoke": "pnpm run build && electron demo/selection-smoke.cjs --copy",
|
|
111
|
+
"demo:smoke": "pnpm run build && electron demo/smoke.cjs",
|
|
112
|
+
"build": "pnpm run clean && pnpm run build:lib && pnpm run build:overlay",
|
|
113
|
+
"build:lib": "tsup",
|
|
114
|
+
"build:overlay": "vite build --config vite.config.ts",
|
|
115
|
+
"lint": "eslint .",
|
|
116
|
+
"typecheck": "tsc --noEmit",
|
|
117
|
+
"test": "vitest run && node --test scripts/verify-release-metadata.test.mjs",
|
|
118
|
+
"test:watch": "vitest",
|
|
119
|
+
"format": "prettier --write .",
|
|
120
|
+
"format:check": "prettier --check .",
|
|
121
|
+
"verify:consumers": "pnpm run build && node scripts/verify-package-consumers.mjs",
|
|
122
|
+
"verify:bundlers": "pnpm run build && node scripts/verify-bundler-consumers.mjs",
|
|
123
|
+
"verify:electron-matrix": "pnpm run build && node scripts/verify-electron-matrix.mjs",
|
|
124
|
+
"verify:packaged": "pnpm run build && node scripts/verify-packaged-consumer.mjs",
|
|
125
|
+
"verify:package:built": "node scripts/verify-package-consumers.mjs && node scripts/verify-bundler-consumers.mjs && node scripts/verify-electron-matrix.mjs && node scripts/verify-packaged-consumer.mjs",
|
|
126
|
+
"verify:package": "pnpm run build && pnpm run verify:package:built",
|
|
127
|
+
"verify:release-metadata": "node scripts/verify-release-metadata.mjs",
|
|
128
|
+
"check": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build",
|
|
129
|
+
"release:check": "pnpm run check && pnpm run verify:release-metadata && pnpm run verify:package:built",
|
|
130
|
+
"prepack": "pnpm run build",
|
|
131
|
+
"prepublishOnly": "pnpm run release:check"
|
|
132
|
+
},
|
|
133
|
+
"engines": {
|
|
134
|
+
"node": ">=20"
|
|
135
|
+
},
|
|
136
|
+
"packageManager": "pnpm@11.19.0",
|
|
137
|
+
"peerDependencies": {
|
|
138
|
+
"electron": ">=42 <44"
|
|
139
|
+
},
|
|
140
|
+
"devDependencies": {
|
|
141
|
+
"@eslint/js": "^10.0.1",
|
|
142
|
+
"@types/node": "^25.3.2",
|
|
143
|
+
"electron": "43.3.0",
|
|
144
|
+
"electron-builder": "^26.15.3",
|
|
145
|
+
"electron-vite": "^5.0.0",
|
|
146
|
+
"eslint": "^10.0.2",
|
|
147
|
+
"globals": "^17.3.0",
|
|
148
|
+
"prettier": "^3.8.1",
|
|
149
|
+
"rimraf": "^6.1.2",
|
|
150
|
+
"tsup": "^8.5.1",
|
|
151
|
+
"typescript": "^5.9.3",
|
|
152
|
+
"typescript-eslint": "^8.56.1",
|
|
153
|
+
"vite": "^7.3.1",
|
|
154
|
+
"vitest": "^4.1.2",
|
|
155
|
+
"webpack": "^5.109.2",
|
|
156
|
+
"webpack-cli": "^7.2.2"
|
|
157
|
+
}
|
|
158
|
+
}
|