@devisfuture/electron-modular 1.1.6 → 1.1.8

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.
Files changed (2) hide show
  1. package/README.md +28 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Package Documentation
2
2
 
3
+ <p align="center">
4
+ <img src="./illustration.png" alt="electron-modular illustration" width="640" />
5
+ </p>
6
+
3
7
  [![npm version](https://img.shields.io/npm/v/@devisfuture/electron-modular.svg)](https://www.npmjs.com/package/@devisfuture/electron-modular) [![Downloads](https://img.shields.io/npm/dm/@devisfuture/electron-modular.svg)](https://www.npmjs.com/package/@devisfuture/electron-modular) [![Build](https://img.shields.io/github/actions/workflow/status/trae-op/electron-modular/ci.yml?branch=main)](https://github.com/trae-op/electron-modular/actions/workflows/ci.yml) [![Coverage](https://img.shields.io/codecov/c/github/trae-op/electron-modular/main)](https://codecov.io/gh/trae-op/electron-modular) [![Bundle size](https://img.shields.io/bundlephobia/minzip/@devisfuture/electron-modular)](https://bundlephobia.com/package/@devisfuture/electron-modular) [![License](https://img.shields.io/npm/l/@devisfuture/electron-modular.svg)](https://github.com/trae-op/electron-modular/blob/main/LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-%233178C6.svg?style=flat&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
4
8
 
5
9
  ## Overview
@@ -338,6 +342,30 @@ export class UserWindow implements TWindowManager {
338
342
  }
339
343
  ```
340
344
 
345
+ ### Preload script — default behavior 🔧
346
+
347
+ By default the framework sets the BrowserWindow's `webPreferences.preload` to the package `preload` file located in the `distMain` folder you configured via `initSettings`. Concretely this resolves to `<app path>/<distMain>/preload.cjs` (production), and the development build is resolved appropriately when running in dev mode.
348
+
349
+ By default the source `preload` file should be placed at `src/main/preload.cts` in your project; it will be compiled/bundled to `preload.cjs` in your configured `distMain` folder during the build step.
350
+
351
+ If you need a custom preload for a specific window, set `options.webPreferences.preload` on the `@WindowManager` config — this will override the framework default:
352
+
353
+ ```ts
354
+ @WindowManager<TWindows["userProfile"]>({
355
+ hash: "window:user-profile",
356
+ isCache: true,
357
+ options: {
358
+ width: 600,
359
+ height: 400,
360
+ webPreferences: {
361
+ preload: '/absolute/or/relative/path/to/custom-preload.js'
362
+ }
363
+ },
364
+ })
365
+ ```
366
+
367
+ > Note: the custom `preload` you provide will override the default `preload` the package injects.
368
+
341
369
  ### Lifecycle Hooks (Window & WebContents events) ✅
342
370
 
343
371
  The window manager supports lifecycle hooks by naming methods on your class following a simple convention:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devisfuture/electron-modular",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "Core module system, DI container, IPC handlers, and window utilities for Electron main process.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",