@dlient/api-types 1.0.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 +39 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/app.d.ts +158 -0
- package/dist/modules/child.d.ts +89 -0
- package/dist/modules/clipboard.d.ts +95 -0
- package/dist/modules/dialog.d.ts +114 -0
- package/dist/modules/fs.d.ts +140 -0
- package/dist/modules/i18n.d.ts +12 -0
- package/dist/modules/log.d.ts +14 -0
- package/dist/modules/net.d.ts +58 -0
- package/dist/modules/notification.d.ts +84 -0
- package/dist/modules/os.d.ts +12 -0
- package/dist/modules/permission.d.ts +72 -0
- package/dist/modules/plugin.d.ts +184 -0
- package/dist/modules/powerSave.d.ts +16 -0
- package/dist/modules/screen.d.ts +84 -0
- package/dist/modules/system.d.ts +14 -0
- package/dist/modules/webview.d.ts +68 -0
- package/package.json +24 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* screen host-api — typed single source.
|
|
3
|
+
* Real source of truth: app/src/main/api/screen.ts (handler reads these fields).
|
|
4
|
+
* All docs are English; keep in sync with the main-process api table.
|
|
5
|
+
*/
|
|
6
|
+
/** A 2D point in DIP or screen coordinates (Electron Point serialized). */
|
|
7
|
+
export interface ScreenPoint {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
/** A 2D size in DIP (Electron Size serialized). */
|
|
12
|
+
export interface ScreenSize {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
/** An axis-aligned rectangle in DIP or screen coordinates (Electron Rectangle serialized). */
|
|
17
|
+
export interface ScreenRect {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}
|
|
23
|
+
/** A display snapshot as returned by the screen module (Electron Display serialized as pure data). */
|
|
24
|
+
export interface ScreenDisplay {
|
|
25
|
+
/** Unique display identifier. */
|
|
26
|
+
id: number;
|
|
27
|
+
/** User-friendly display label. */
|
|
28
|
+
label: string;
|
|
29
|
+
/** Display bounds in DIP. */
|
|
30
|
+
bounds: ScreenRect;
|
|
31
|
+
/** Work-area bounds (taskbar excluded) in DIP. */
|
|
32
|
+
workArea: ScreenRect;
|
|
33
|
+
/** Display size in DIP. */
|
|
34
|
+
size: ScreenSize;
|
|
35
|
+
/** Work-area size in DIP. */
|
|
36
|
+
workAreaSize: ScreenSize;
|
|
37
|
+
/** DIP scale factor (e.g. 1 for 100%, 2 for 200%). */
|
|
38
|
+
scaleFactor: number;
|
|
39
|
+
/** Display rotation in degrees (0 / 90 / 180 / 270). */
|
|
40
|
+
rotation: number;
|
|
41
|
+
/** Whether this is an internal (built-in) display. */
|
|
42
|
+
internal: boolean;
|
|
43
|
+
/** Touch support capability reported by the OS. */
|
|
44
|
+
touchSupport: 'available' | 'unavailable' | 'unknown';
|
|
45
|
+
/** Whether the display is monochrome. */
|
|
46
|
+
monochrome: boolean;
|
|
47
|
+
/** Accelerometer support capability reported by the OS. */
|
|
48
|
+
accelerometerSupport: 'available' | 'unavailable' | 'unknown';
|
|
49
|
+
/** Display color space (e.g. 'srgb'; Windows only). */
|
|
50
|
+
colorSpace: string;
|
|
51
|
+
/** Number of bits per pixel. */
|
|
52
|
+
colorDepth: number;
|
|
53
|
+
/** Number of bits per color component. */
|
|
54
|
+
depthPerComponent: number;
|
|
55
|
+
/** Display refresh rate in Hz. */
|
|
56
|
+
displayFrequency: number;
|
|
57
|
+
}
|
|
58
|
+
/** Flat signature map for the screen module. */
|
|
59
|
+
export type ScreenModuleApi = {
|
|
60
|
+
/** Current absolute cursor position in DIP. */
|
|
61
|
+
'screen.getCursorScreenPoint'(): Promise<ScreenPoint>;
|
|
62
|
+
/** Info of the primary display. */
|
|
63
|
+
'screen.getPrimaryDisplay'(): Promise<ScreenDisplay>;
|
|
64
|
+
/** Info of all currently available displays. */
|
|
65
|
+
'screen.getAllDisplays'(): Promise<ScreenDisplay[]>;
|
|
66
|
+
/** The display nearest the given point. */
|
|
67
|
+
'screen.getDisplayNearestPoint'(point: ScreenPoint): Promise<ScreenDisplay>;
|
|
68
|
+
/** The display that most intersects the given rectangle. */
|
|
69
|
+
'screen.getDisplayMatching'(rect: ScreenRect): Promise<ScreenDisplay>;
|
|
70
|
+
/** Converts a physical screen point to a DIP point (Windows / Linux). */
|
|
71
|
+
'screen.screenToDipPoint'(point: ScreenPoint): Promise<ScreenPoint>;
|
|
72
|
+
/** Converts a DIP point to a physical screen point (Windows / Linux). */
|
|
73
|
+
'screen.dipToScreenPoint'(point: ScreenPoint): Promise<ScreenPoint>;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a physical screen rect to a DIP rect (Windows).
|
|
76
|
+
* The window argument is not serializable over the host api — always pass null.
|
|
77
|
+
*/
|
|
78
|
+
'screen.screenToDipRect'(window: null, rect: ScreenRect): Promise<ScreenRect>;
|
|
79
|
+
/**
|
|
80
|
+
* Converts a DIP rect to a physical screen rect (Windows).
|
|
81
|
+
* The window argument is not serializable over the host api — always pass null.
|
|
82
|
+
*/
|
|
83
|
+
'screen.dipToScreenRect'(window: null, rect: ScreenRect): Promise<ScreenRect>;
|
|
84
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* system host-api — typed single source.
|
|
3
|
+
* Real source of truth: app/src/main/api/system.ts (handler reads these fields).
|
|
4
|
+
* All docs are English; keep in sync with the main-process api table.
|
|
5
|
+
*/
|
|
6
|
+
/** Idle states reported by system.getIdleState (Electron powerMonitor). */
|
|
7
|
+
export type SystemIdleState = 'active' | 'idle' | 'locked' | 'unknown';
|
|
8
|
+
/** Flat signature map for the system module. */
|
|
9
|
+
export type SystemModuleApi = {
|
|
10
|
+
/** System idle state; the system is 'idle' after thresholdSeconds of inactivity. Defaults to 5 seconds. */
|
|
11
|
+
'system.getIdleState'(thresholdSeconds?: number): Promise<SystemIdleState>;
|
|
12
|
+
/** Enables/disables OS theme following; while enabled, OS theme changes are forwarded to the renderer. */
|
|
13
|
+
'system.listenNativeTheme'(enabled: boolean): Promise<void>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* webview host-api — typed single source.
|
|
3
|
+
* Real source of truth: app/src/main/api/webview.ts (handler reads these fields).
|
|
4
|
+
* All docs are English; keep in sync with the main-process api table.
|
|
5
|
+
*/
|
|
6
|
+
/** Rect bounds of a webview, in DIP. */
|
|
7
|
+
export interface WebviewBounds {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
/** Whitelisted webContents events the host forwards to the owning plugin worker (as `onWebContentsEvent`). */
|
|
14
|
+
export type WebviewEventName = 'did-finish-load' | 'did-fail-load' | 'did-start-loading' | 'did-stop-loading' | 'page-title-updated' | 'did-navigate' | 'did-navigate-in-page' | 'will-navigate';
|
|
15
|
+
/** webContents methods the host allows webview.webContentsCall to invoke (method whitelist). */
|
|
16
|
+
export type WebviewWebContentsMethod = 'loadURL' | 'reload' | 'stop' | 'goBack' | 'goForward' | 'getURL' | 'getTitle' | 'executeJavaScript' | 'setZoomLevel' | 'getZoomLevel';
|
|
17
|
+
/** Options accepted by webview.create. */
|
|
18
|
+
export interface WebviewCreateOptions {
|
|
19
|
+
/** URL to load once the view is created. */
|
|
20
|
+
src?: string;
|
|
21
|
+
/** Initial view bounds (0,0,0,0 when omitted — set bounds right after via webview.update). */
|
|
22
|
+
bounds?: WebviewBounds;
|
|
23
|
+
/** WebPreferences passthrough; only 'partition' and 'userAgent' are honored, security-sensitive options (sandbox/contextIsolation/nodeIntegration) are always forced by the host. */
|
|
24
|
+
webPreferences?: {
|
|
25
|
+
partition?: string;
|
|
26
|
+
userAgent?: string;
|
|
27
|
+
};
|
|
28
|
+
/** Whitelisted webContents events to subscribe; their payloads are forwarded to the owning plugin worker. */
|
|
29
|
+
events?: WebviewEventName[];
|
|
30
|
+
}
|
|
31
|
+
/** Result of webview.create. */
|
|
32
|
+
export interface WebviewCreateResult {
|
|
33
|
+
viewId: string;
|
|
34
|
+
}
|
|
35
|
+
/** Options accepted by webview.update (re-bounds an existing view). */
|
|
36
|
+
export interface WebviewUpdateOptions {
|
|
37
|
+
viewId: string;
|
|
38
|
+
bounds: WebviewBounds;
|
|
39
|
+
}
|
|
40
|
+
/** Options accepted by webview.setVisible (component-level visibility override; owner visibility alignment still applies). */
|
|
41
|
+
export interface WebviewSetVisibleOptions {
|
|
42
|
+
viewId: string;
|
|
43
|
+
visible: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Options accepted by webview.webContentsCall (invokes a whitelisted webContents method with JSON-serializable args). */
|
|
46
|
+
export interface WebviewWebContentsCallOptions {
|
|
47
|
+
viewId: string;
|
|
48
|
+
method: WebviewWebContentsMethod;
|
|
49
|
+
/** Arguments forwarded to the method; only JSON-serializable values survive the host round-trip. */
|
|
50
|
+
args?: unknown[];
|
|
51
|
+
}
|
|
52
|
+
/** Flat signature map for the webview module. */
|
|
53
|
+
export type WebviewModuleApi = {
|
|
54
|
+
/** Creates an embedded webview owned by the currently active plugin (visibility follows the owner-alignment rule). */
|
|
55
|
+
'webview.create'(options: WebviewCreateOptions): Promise<WebviewCreateResult>;
|
|
56
|
+
/** Updates the bounds of an existing webview (no-op when the id is unknown). */
|
|
57
|
+
'webview.update'(options: WebviewUpdateOptions): Promise<void>;
|
|
58
|
+
/** Destroys a webview by id (no-op when the id is unknown). */
|
|
59
|
+
'webview.destroy'(viewId: string): Promise<void>;
|
|
60
|
+
/** Sets the component-level visibility of a webview. */
|
|
61
|
+
'webview.setVisible'(options: WebviewSetVisibleOptions): Promise<void>;
|
|
62
|
+
/** Calls a whitelisted webContents method (navigation / title / zoom / executeJavaScript); other methods are rejected. Returns the method's result. */
|
|
63
|
+
'webview.webContentsCall'(options: WebviewWebContentsCallOptions): Promise<unknown>;
|
|
64
|
+
/** Shows the caller plugin's webviews again; when views is given only those exact ids are restored (pair with webview.hideWebviewByPlugin's result). */
|
|
65
|
+
'webview.showWebviewByPlugin'(views?: string[]): Promise<void>;
|
|
66
|
+
/** Hides all of the caller plugin's webviews and returns the hidden view ids (pass them back to webview.showWebviewByPlugin for exact restore). */
|
|
67
|
+
'webview.hideWebviewByPlugin'(): Promise<string[]>;
|
|
68
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dlient/api-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "vite build && tsc -p tsconfig.json"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.4.0",
|
|
22
|
+
"vite": "^5.1.6"
|
|
23
|
+
}
|
|
24
|
+
}
|