@devisfuture/electron-modular 1.1.7 → 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 +24 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -342,6 +342,30 @@ export class UserWindow implements TWindowManager {
342
342
  }
343
343
  ```
344
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
+
345
369
  ### Lifecycle Hooks (Window & WebContents events) ✅
346
370
 
347
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.7",
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",