@bouko/electron 1.1.2 → 1.1.4

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/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import "./ipc";
1
2
  export * from "./communication";
2
3
  export * from "./csp";
3
4
  export * from "./files/_";
5
+ export * from "./window";
package/dist/index.js CHANGED
@@ -2,3 +2,4 @@
2
2
  export * from "./communication";
3
3
  export * from "./csp";
4
4
  export * from "./files/_";
5
+ export * from "./window";
@@ -0,0 +1,10 @@
1
+ import { BrowserWindow } from "electron";
2
+ export type MainWindowConfig = {
3
+ entry: string;
4
+ preload: string;
5
+ width: number;
6
+ height: number;
7
+ icon?: string;
8
+ };
9
+ export declare function createMainWindow(config: MainWindowConfig): BrowserWindow;
10
+ export declare const getMainWindow: () => BrowserWindow | null;
@@ -0,0 +1,24 @@
1
+ import { BrowserWindow } from "electron";
2
+ let mainWindow = null;
3
+ export function createMainWindow(config) {
4
+ if (mainWindow && !mainWindow.isDestroyed())
5
+ return mainWindow;
6
+ mainWindow = new BrowserWindow({
7
+ width: config.width,
8
+ height: config.height,
9
+ icon: config.icon,
10
+ show: false,
11
+ frame: false,
12
+ resizable: false,
13
+ webPreferences: {
14
+ preload: config.preload,
15
+ contextIsolation: true,
16
+ nodeIntegration: false
17
+ }
18
+ });
19
+ mainWindow.once("ready-to-show", () => mainWindow?.show());
20
+ mainWindow.on("closed", () => (mainWindow = null));
21
+ void mainWindow.loadURL(config.entry);
22
+ return mainWindow;
23
+ }
24
+ export const getMainWindow = () => mainWindow;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/electron",
4
- "version": "1.1.2",
4
+ "version": "1.1.4",
5
5
  "description": "",
6
6
  "keywords": [],
7
7
  "author": "",
@@ -15,7 +15,10 @@
15
15
  "access": "public"
16
16
  },
17
17
  "exports": {
18
- ".": "./dist/index.js",
18
+ ".": {
19
+ "default": "./dist/index.js",
20
+ "types": "./dist/index.d.ts"
21
+ },
19
22
  "./types": "./dist/index.d.ts",
20
23
  "./styles.css": "./dist/styles.css"
21
24
  },