@talex-touch/utils 1.0.8 → 1.0.10

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "./index.ts",
6
6
  "license": "MPL-2.0",
7
7
  "private": false,
8
- "version": "1.0.8",
8
+ "version": "1.0.10",
9
9
  "scripts": {
10
10
  "publish": "npm publish --access public"
11
11
  },
package/plugin/channel.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // const { ipcRenderer, IpcMainEvent } = require("electron");
2
- import { ipcRenderer, IpcRendererEvent } from "electron/main";
2
+ import { ipcRenderer, IpcRendererEvent } from "electron";
3
3
  import {
4
4
  ChannelType,
5
5
  DataCode,
@@ -15,16 +15,4 @@ export function regShortcut(key: string, func: Function) {
15
15
  return true;
16
16
  }
17
17
 
18
- export function createWindow(options: BrowserWindowConstructorOptions & { file?: string } & { url?: string }): number {
19
- const res = genChannel().sendSync('window:new', options)
20
- if ( res.error ) throw new Error(res.error)
21
-
22
- return res.id
23
- }
24
-
25
- export function toggleWinVisible(id: number, visible?: boolean): boolean {
26
- const res = genChannel().sendSync('window:visible', visible !== undefined ? { id, visible } : { id })
27
- if ( res.error ) throw new Error(res.error)
28
-
29
- return res.visible
30
- }
18
+ export * from './window';
@@ -0,0 +1,40 @@
1
+ import { genChannel } from '../../channel';
2
+ import {
3
+ BrowserWindowConstructorOptions, BrowserWindow, WebContents
4
+ } from "electron";
5
+
6
+ export function createWindow(options: BrowserWindowConstructorOptions & { file?: string } & { url?: string }): number {
7
+ const res = genChannel().sendSync('window:new', options)
8
+ if (res.error) throw new Error(res.error)
9
+
10
+ return res.id
11
+ }
12
+
13
+ export function toggleWinVisible(id: number, visible?: boolean): boolean {
14
+ const res = genChannel().sendSync('window:visible', visible !== undefined ? { id, visible } : { id })
15
+ if (res.error) throw new Error(res.error)
16
+
17
+ return res.visible
18
+ }
19
+
20
+ export function setWindowProperty<K extends keyof BrowserWindow, V>(id: number, property: {
21
+
22
+ }): boolean {
23
+ const res = genChannel().sendSync('window:property', { id, property })
24
+ if (res.error) throw new Error(res.error)
25
+
26
+ return res.success
27
+ }
28
+
29
+ export type WindowProperty = {
30
+ [P in keyof BrowserWindow]?: BrowserWindow[P]
31
+ }
32
+
33
+ export type WebContentsProperty = {
34
+ [P in keyof WebContents]?: WebContents[P]
35
+ }
36
+
37
+ export interface WindowProperties {
38
+ window?: WindowProperty
39
+ webContents?: WebContentsProperty
40
+ }