@tomjs/vite-plugin-electron 1.11.0 → 2.0.1

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 CHANGED
@@ -10,7 +10,7 @@ Many thanks to [caoxiemeihao](https://github.com/caoxiemeihao)'s [vite-plugin-el
10
10
 
11
11
  ## Features
12
12
 
13
- - Fast build `main` and `preload` with [tsup](https://github.com/egoist/tsup)
13
+ - Fast build `main` and `preload` with [tsdwon](https://tsdown.dev/)
14
14
  - Little configuration, focus on business
15
15
  - Support `main`'s `Hot Restart`
16
16
  - Support `preload`'s `Hot Reload`
@@ -90,6 +90,7 @@ See [PluginOptions](#pluginoptions) and `recommended` parameter descriptions in
90
90
  ```ts
91
91
  import { dirname } from 'node:path';
92
92
  import { fileURLToPath } from 'node:url';
93
+ import { ELECTRON_EXIT } from '@tomjs/vite-plugin-electron/electron';
93
94
  import { app, BrowserWindow } from 'electron';
94
95
 
95
96
  // when package.json "type": module"
@@ -119,6 +120,15 @@ async function createWindow() {
119
120
  }
120
121
 
121
122
  app.whenReady().then(createWindow);
123
+
124
+ process.on('message', (data) => {
125
+ // When restarting the electron, if devTools is turned on, the electron may not be able to shut down normally.
126
+ if (data === ELECTRON_EXIT) {
127
+ if (win) {
128
+ win.webContents.closeDevTools();
129
+ }
130
+ }
131
+ });
122
132
  ```
123
133
 
124
134
  ### vue
@@ -143,6 +153,7 @@ Electron `preload process` must use the `.mjs` suffix, otherwise an error will b
143
153
  import electron from '@tomjs/vite-plugin-electron';
144
154
  import vue from '@vitejs/plugin-vue';
145
155
  import { defineConfig } from 'vite';
156
+
146
157
  export default defineConfig({
147
158
  plugins: [
148
159
  vue(),
@@ -189,7 +200,7 @@ export default defineConfig({
189
200
 
190
201
  ## Documentation
191
202
 
192
- - [index.d.ts](https://www.unpkg.com/browse/@tomjs/vite-plugin-electron/dist/index.d.ts) provided by [unpkg.com](https://www.unpkg.com).
203
+ - [index.d.mts](https://www.unpkg.com/browse/@tomjs/vite-plugin-electron/dist/index.d.mts) provided by [unpkg.com](https://www.unpkg.com).
193
204
 
194
205
  ## Parameters
195
206
 
@@ -198,7 +209,7 @@ export default defineConfig({
198
209
  | Property | Type | Default | Description |
199
210
  | ----------- | ---------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
200
211
  | recommended | `boolean` | `true` | This option is intended to provide recommended default parameters and behavior. |
201
- | external | `string[]` | | Don't bundle these modules, but dependencies and peerDependencies in your package.json are always excluded.[See more](https://tsup.egoist.dev/#excluding-packages) |
212
+ | external | `string[]` | | Don't bundle these modules, but dependencies and peerDependencies in your package.json are always excluded.[See more](https://tsdown.dev/reference/api/Interface.UserConfig#external) |
202
213
  | main | [MainOptions](#MainOptions) | | Configuration options for the electron main process. |
203
214
  | preload | [PreloadOptions](#PreloadOptions) | | Configuration options for the electron preload process. |
204
215
  | debug | `boolean` | `false` | Electron debug mode, don't startup electron. You can also use `process.env.VITE_ELECTRON_DEBUG`. Default is false. |
@@ -215,25 +226,27 @@ The `recommended` option is used to set the default configuration and behavior,
215
226
 
216
227
  ### MainOptions
217
228
 
218
- Based on [Options](https://www.jsdocs.io/package/tsup) of [tsup](https://tsup.egoist.dev/), some default values are added for ease of use.
229
+ Based on [Options](https://tsdown.dev/reference/api/Interface.UserConfig) of [tsdown](https://tsdown.dev), some default values are added for ease of use.
219
230
 
220
- | Property | Type | Default | Description |
221
- | --------- | ------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------ |
222
- | entry | `string` | `-` | The main process entry file. |
223
- | format | `'cjs' \| 'esm'` | `-` | The bundle format. If not specified, it will use the "type" field from package.json. |
224
- | outDir | `string` | "dist-electron/main" | The output directory for the main process files |
225
- | onSuccess | `() => Promise<void \| undefined \| (() => void \| Promise<void>)>` | `undefined` | A function that will be executed after the build succeeds. |
231
+ | Property | Type | Default | Description |
232
+ | ----------- | ----------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
233
+ | entry | `string` | `-` | The main process entry file. |
234
+ | format | `'cjs' \| 'esm'` | `-` | The bundle format. If not specified, it will use the "type" field from package.json. |
235
+ | outDir | `string` | "dist-electron/main" | The output directory for the main process files |
236
+ | watchFiles | `string \| string[]` | `undefined` | Watch Electron related files or folders.If `recommended:true`, it will monitor the `electron/main` directory; otherwise, you need to specify the directory corresponding to the Electron code. Failure to specify may cause Electron to restart indefinitely. |
237
+ | ignoreWatch | `Arrayable<string \| RegExp>` | `'.history', '.temp', '.tmp', '.cache', 'dist'` | Ignore files or folders being watched |
226
238
 
227
239
  ### PreloadOptions
228
240
 
229
- Based on [Options](https://www.jsdocs.io/package/tsup) of [tsup](https://tsup.egoist.dev/), some default values are added for ease of use.
241
+ Based on [Options](https://tsdown.dev/reference/api/Interface.UserConfig) of [tsdown](https://tsdown.dev), some default values are added for ease of use.
230
242
 
231
- | Property | Type | Default | Description |
232
- | --------- | ------------------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------ |
233
- | entry | `string` | `-` | The preload process entry file. |
234
- | format | `'cjs' \| 'esm'` | `-` | The bundle format. If not specified, it will use the "type" field from package.json. |
235
- | outDir | `string` | "dist-electron/preload" | The output directory for the preload process files |
236
- | onSuccess | `() => Promise<void \| undefined \| (() => void \| Promise<void>)>` | `undefined` | A function that will be executed after the build succeeds. |
243
+ | Property | Type | Default | Description |
244
+ | ----------- | ----------------------------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
245
+ | entry | `string` | `-` | The preload process entry file. |
246
+ | format | `'cjs' \| 'esm'` | `-` | The bundle format. If not specified, it will use the "type" field from package.json. |
247
+ | outDir | `string` | "dist-electron/preload" | The output directory for the preload process files |
248
+ | watchFiles | `string \| string[]` | `undefined` | Watch Electron related files or folders.If `recommended:true`, it will monitor the `electron/preload` directory; otherwise, you need to specify the directory corresponding to the Electron code. Failure to specify may cause Electron to restart indefinitely. |
249
+ | ignoreWatch | `Arrayable<string \| RegExp>` | `'.history', '.temp', '.tmp', '.cache', 'dist'` | Ignore files or folders being watched |
237
250
 
238
251
  ### BuilderOptions
239
252
 
@@ -334,6 +347,9 @@ app.whenReady().then(() => {
334
347
 
335
348
  installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
336
349
  .then((exts) => {
350
+ // Install the extension before enabling the developer tools; otherwise, the extension may fail to load.
351
+ // win.webContents.openDevTools();
352
+
337
353
  console.log(
338
354
  'Added Extension: ',
339
355
  exts.map(s => s.name),
@@ -430,3 +446,12 @@ Open the [examples](./examples) directory, there are `vue` and `react` examples.
430
446
 
431
447
  - [react](./examples/react)
432
448
  - [vue](./examples/vue)
449
+
450
+ ## Important Notes
451
+
452
+ ### v2.0.0
453
+
454
+ **Breaking Updates:**
455
+
456
+ - Using [tsdown](https://tsdown.dev/zh-CN) instead of [tsup](https://tsup.egoist.dev/), the main/preload configuration is changed to inherit [tsdown](https://tsdown.dev/zh-CN).
457
+ - If `recommended:true` is not used, `watchFiles` needs to be configured. See [MainOptions](#mainoptions) and [PreloadOptions](#preloadoptions) for details.
package/README.zh_CN.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## 特性
12
12
 
13
- - 使用 [tsup](https://github.com/egoist/tsup) 快速构建 `main` 和 `preload`
13
+ - 使用 [tsdown](https://tsdown.dev) 快速构建 `main` 和 `preload`
14
14
  - 配置简单,专注业务
15
15
  - 支持 `main` 的 `热重启`
16
16
  - 支持 `preload` 的 `热重载`
@@ -90,6 +90,7 @@ npm i electron-builder --save-dev
90
90
  ```ts
91
91
  import { dirname } from 'node:path';
92
92
  import { fileURLToPath } from 'node:url';
93
+ import { ELECTRON_EXIT } from '@tomjs/vite-plugin-electron/electron';
93
94
  import { app, BrowserWindow } from 'electron';
94
95
 
95
96
  // when package.json "type": module"
@@ -97,6 +98,7 @@ globalThis.__dirname = dirname(fileURLToPath(import.meta.url));
97
98
 
98
99
  const preload = join(__dirname, '../preload/index.mjs');
99
100
  const url = process.env.VITE_DEV_SERVER_URL;
101
+ let win: BrowserWindow | null = null;
100
102
 
101
103
  async function createWindow() {
102
104
  win = new BrowserWindow({
@@ -119,6 +121,15 @@ async function createWindow() {
119
121
  }
120
122
 
121
123
  app.whenReady().then(createWindow);
124
+
125
+ process.on('message', (data) => {
126
+ // 重启 electron 时,如果 devTools 打开可能会造成 electron 无法正常关闭
127
+ if (data === ELECTRON_EXIT) {
128
+ if (win) {
129
+ win.webContents.closeDevTools();
130
+ }
131
+ }
132
+ });
122
133
  ```
123
134
 
124
135
  ### vue
@@ -190,7 +201,7 @@ export default defineConfig({
190
201
 
191
202
  ## 文档
192
203
 
193
- - [unpkg.com](https://www.unpkg.com/) 提供的 [index.d.ts](https://www.unpkg.com/browse/@tomjs/vite-plugin-electron/dist/index.d.ts).
204
+ - [unpkg.com](https://www.unpkg.com/) 提供的 [index.d.mts](https://app.unpkg.com/@tomjs/vite-plugin-electron@2.0.0/files/dist/index.d.mts).
194
205
 
195
206
  ## 参数
196
207
 
@@ -199,7 +210,7 @@ export default defineConfig({
199
210
  | 参数名 | 类型 | 默认值 | 说明 |
200
211
  | ----------- | --------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
201
212
  | recommended | `boolean` | `true` | 这个选项是为了提供推荐的默认参数和行为 |
202
- | external | `string[]` | | 不打包这些模块,但是 `dependencies` and `peerDependencies` 默认排除,[详见](https://tsup.egoist.dev/#excluding-packages) |
213
+ | external | `string[]` | | 不打包这些模块,但是 `dependencies` and `peerDependencies` 默认排除,[详见](https://tsdown.dev/zh-CN/reference/api/Interface.UserConfig) |
203
214
  | main | [MainOptions](#MainOptions) | | electron main 进程选项 |
204
215
  | preload | [PreloadOptions](#PreloadOptions) | | electron preload 进程选项 |
205
216
  | debug | `boolean` | `false` | Electron调试模式,不启动Electron。 您还可以使用 `process.env.VITE_ELECTRON_DEBUG` |
@@ -214,25 +225,27 @@ export default defineConfig({
214
225
 
215
226
  ### MainOptions
216
227
 
217
- 继承自 [tsup](https://tsup.egoist.dev/) 的 [Options](https://www.jsdocs.io/package/tsup),添加了一些默认值,方便使用。
228
+ 继承自 [tsdown](https://tsdown.dev/) 的 [Options](https://tsdown.dev/zh-CN/reference/api/Interface.UserConfig),添加了一些默认值,方便使用。
218
229
 
219
- | 参数名 | 类型 | 默认值 | 说明 |
220
- | --------- | ------------------------------------------------------------------- | ---------------------- | ---------------------------------------------------------- |
221
- | **entry** | `string` | `-` | main 入口文件 |
222
- | format | `'cjs' \| 'esm'` | `-` | 打包格式。如果未指定,将使用 package.json 中的 "type" 字段 |
223
- | outDir | `string` | `"dist-electron/main"` | main 输出文件夹 |
224
- | onSuccess | `() => Promise<void \| undefined \| (() => void \| Promise<void>)>` | `undefined` | 构建成功后运行的回调函数 |
230
+ | 参数名 | 类型 | 默认值 | 说明 |
231
+ | ----------- | ----------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
232
+ | **entry** | `string` | `-` | main 入口文件 |
233
+ | format | `'cjs' \| 'esm'` | `-` | 打包格式。如果未指定,将使用 package.json 中的 "type" 字段 |
234
+ | outDir | `string` | `"dist-electron/main"` | main 输出文件夹 |
235
+ | watchFiles | `string \| string[]` | `undefined` | 监听 electron 相关文件或文件夹。如果 `recommended:true`,则监听 `electron/main` 目录,否则需要指定 electron 代码对应目录,如果没有指定可能会造成 electron 无限重启 |
236
+ | ignoreWatch | `Arrayable<string \| RegExp>` | `'.history', '.temp', '.tmp', '.cache', 'dist'` | 忽略监听的文件或文件夹 |
225
237
 
226
238
  ### PreloadOptions
227
239
 
228
- 继承自 [tsup](https://tsup.egoist.dev/) 的 [Options](https://www.jsdocs.io/package/tsup),添加了一些默认值,方便使用。
240
+ 继承自 [tsdown](https://tsdown.dev) 的 [Options](https://tsdown.dev/zh-CN/reference/api/Interface.UserConfig),添加了一些默认值,方便使用。
229
241
 
230
- | 参数名 | 类型 | 默认值 | 说明 |
231
- | --------- | ------------------------------------------------------------------- | ------------------------- | ---------------------------------------------------------- |
232
- | **entry** | `string` | `-` | preload 入口文件 |
233
- | format | `'cjs' \| 'esm'` | `-` | 打包格式。如果未指定,将使用 package.json 中的 "type" 字段 |
234
- | outDir | `string` | `"dist-electron/preload"` | preload 输出文件夹 |
235
- | onSuccess | `() => Promise<void \| undefined \| (() => void \| Promise<void>)>` | `undefined` | 构建成功后运行的回调函数 |
242
+ | 参数名 | 类型 | 默认值 | 说明 |
243
+ | ----------- | ----------------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
244
+ | **entry** | `string` | `-` | preload 入口文件 |
245
+ | format | `'cjs' \| 'esm'` | `-` | 打包格式。如果未指定,将使用 package.json 中的 "type" 字段 |
246
+ | outDir | `string` | `"dist-electron/preload"` | preload 输出文件夹 |
247
+ | watchFiles | `string \| string[]` | `undefined` | 监听 electron 相关文件或文件夹。如果 `recommended:true`,则监听 `electron/preload` 目录,否则需要指定 electron 代码对应目录,如果没有指定可能会造成 electron 无限重启 |
248
+ | ignoreWatch | `Arrayable<string \| RegExp>` | `'.history', '.temp', '.tmp', '.cache', 'dist'` | 忽略监听的文件或文件夹 |
236
249
 
237
250
  ### BuilderOptions
238
251
 
@@ -305,7 +318,7 @@ const config = {
305
318
 
306
319
  | 变量 | 描述 |
307
320
  | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
308
- | `VITE_ELECTRON_DEBUG` | Electron主进程调试,不要启动Electron。 当值为 true 或 1 时启用,为 false 或 0 时禁用。默认值未定义。 |
321
+ | `VITE_ELECTRON_DEBUG` | Electron主进程调试,不启动Electron。 当值为 true 或 1 时启用,为 false 或 0 时禁用。默认值未定义。 |
309
322
  | `VITE_ELECTRON_INSPECT` | Electron 将在指定端口上侦听 V8 检查器协议消息,外部调试器需要连接到该端口。 当值为 true 时,默认端口为 5858。 |
310
323
  | `VITE_ELECTRON_BUILDER` | 启用 [ Electron-builder ](https://www.electron.build) 进行打包。 当值为 true 或 1 时启用,为 false 或 0 时禁用。 默认值未定义。 |
311
324
 
@@ -333,6 +346,9 @@ app.whenReady().then(() => {
333
346
 
334
347
  installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
335
348
  .then((exts) => {
349
+ // 安装扩展后再开启开发者工具,否则可能会出现扩展加载失败问题
350
+ // win.webContents.openDevTools();
351
+
336
352
  console.log(
337
353
  'Added Extension: ',
338
354
  exts.map(s => s.name),
@@ -429,3 +445,12 @@ pnpm build
429
445
 
430
446
  - [react](./examples/react)
431
447
  - [vue](./examples/vue)
448
+
449
+ ## 重要说明
450
+
451
+ ### v2.0.0
452
+
453
+ **破坏性更新:**
454
+
455
+ - 使用 [tsdown](https://tsdown.dev/zh-CN) 替代 [tsup](https://tsup.egoist.dev/),main/preload 配置改为继承 [tsdown](https://tsdown.dev/zh-CN).
456
+ - 如果没有使用 `recommended:true`,需要配置 `watchFiles`,详见 [MainOptions](#mainoptions)和 [PreloadOptions](#preloadoptions)
@@ -0,0 +1,8 @@
1
+ //#region src/electron.ts
2
+ /**
3
+ * electron exit message
4
+ */
5
+ const ELECTRON_EXIT = "tomjs:electron:exit";
6
+
7
+ //#endregion
8
+ export { ELECTRON_EXIT as t };
@@ -0,0 +1,7 @@
1
+ //#region src/electron.d.ts
2
+ /**
3
+ * electron exit message
4
+ */
5
+ declare const ELECTRON_EXIT = "tomjs:electron:exit";
6
+ //#endregion
7
+ export { ELECTRON_EXIT };
@@ -0,0 +1,3 @@
1
+ import { t as ELECTRON_EXIT } from "./electron-BUQU2XNS.mjs";
2
+
3
+ export { ELECTRON_EXIT };
package/dist/index.d.mts CHANGED
@@ -1,54 +1,60 @@
1
- import { Plugin } from 'vite';
2
- import { Configuration } from 'electron-builder';
3
- import { Options } from 'tsup';
1
+ import { UserConfig } from "tsdown";
2
+ import { Configuration } from "electron-builder";
3
+ import { Plugin } from "vite";
4
+
5
+ //#region src/types.d.ts
4
6
 
5
7
  /**
6
8
  * Electron main process options. See [tsup](https://tsup.egoist.dev/) and [API Doc](https://www.jsdocs.io/package/tsup) for more information.
7
9
  * @see https://www.jsdocs.io/package/tsup
8
10
  * @see https://unpkg.com/browse/tsup/dist/index.d.ts
9
11
  */
10
- interface MainOptions extends Omit<Options, 'entry' | 'format' | 'outDir' | 'watch' | 'onSuccess'> {
11
- /**
12
- * The main process entry file.
13
- */
14
- entry?: string;
15
- /**
16
- * The bundle format. If not specified, it will use the "type" field from package.json.
17
- */
18
- format?: 'cjs' | 'esm';
19
- /**
20
- * The output directory for the main process files. Defaults to `"dist-electron/main"`.
21
- * @default "dist-electron/main"
22
- */
23
- outDir?: string;
24
- /**
25
- * A function that will be executed after the build succeeds.
26
- */
27
- onSuccess?: () => Promise<void | undefined | (() => void | Promise<void>)>;
12
+ interface MainOptions extends Omit<UserConfig, 'entry' | 'format' | 'outDir' | 'watch'> {
13
+ /**
14
+ * The main process entry file.
15
+ */
16
+ entry?: string;
17
+ /**
18
+ * The bundle format. If not specified, it will use the "type" field from package.json.
19
+ */
20
+ format?: 'cjs' | 'esm';
21
+ /**
22
+ * The output directory for the main process files. Defaults to `"dist-electron/main"`.
23
+ * @default "dist-electron/main"
24
+ */
25
+ outDir?: string;
26
+ /**
27
+ * `tsdown` watches the current working directory by default. You can set files that need to be watched, which may improve performance.
28
+ *
29
+ * If no value is specified, the default value of the "recommended" parameter is ["dist-electron"] when it is true, otherwise 'watch' defaults to "true"
30
+ */
31
+ watchFiles?: string | string[];
28
32
  }
29
33
  /**
30
34
  * Electron preload process options. See [tsup](https://tsup.egoist.dev/) and [API Doc](https://www.jsdocs.io/package/tsup) for more information.
31
35
  * @see https://www.jsdocs.io/package/tsup
32
36
  * @see https://unpkg.com/browse/tsup/dist/index.d.ts
33
37
  */
34
- interface PreloadOptions extends Omit<Options, 'entry' | 'format' | 'outDir' | 'watch' | 'onSuccess'> {
35
- /**
36
- * The preload process entry file
37
- */
38
- entry?: string | string[] | Record<string, string>;
39
- /**
40
- * The bundle format. If not specified, it will use the "type" field from package.json.
41
- */
42
- format?: 'cjs' | 'esm';
43
- /**
44
- * The output directory for the preload process files. Defaults is `"dist-electron/preload"`.
45
- * @default "dist-electron/preload"
46
- */
47
- outDir?: string;
48
- /**
49
- * A function that will be executed after the build succeeds.
50
- */
51
- onSuccess?: () => Promise<void | undefined | (() => void | Promise<void>)>;
38
+ interface PreloadOptions extends Omit<UserConfig, 'entry' | 'format' | 'outDir' | 'watch'> {
39
+ /**
40
+ * The preload process entry file
41
+ */
42
+ entry?: string | string[] | Record<string, string>;
43
+ /**
44
+ * The bundle format. If not specified, it will use the "type" field from package.json.
45
+ */
46
+ format?: 'cjs' | 'esm';
47
+ /**
48
+ * The output directory for the preload process files. Defaults is `"dist-electron/preload"`.
49
+ * @default "dist-electron/preload"
50
+ */
51
+ outDir?: string;
52
+ /**
53
+ * `tsdown` watches the current working directory by default. You can set files that need to be watched, which may improve performance.
54
+ *
55
+ * If no value is specified, the default value of the "recommended" parameter is ["dist-electron"] when it is true, otherwise 'watch' defaults to "true"
56
+ */
57
+ watchFiles?: string | string[];
52
58
  }
53
59
  /**
54
60
  * When `recommended` and `builder.enable` are both `true`, use [electron-builder](https://www.electron.build) to package Electron applications.
@@ -57,79 +63,74 @@ interface PreloadOptions extends Omit<Options, 'entry' | 'format' | 'outDir' | '
57
63
  * Execute `npm install` and then package.
58
64
  */
59
65
  interface BuilderOptions {
60
- /**
61
- * Whether to enable the [electron-builder](https://www.electron.build), the default is false.
62
- * @default false
63
- * @deprecated
64
- */
65
- enable?: boolean;
66
- /**
67
- * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as
68
- * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.
69
- * @default com.electron.${name}
70
- */
71
- appId?: string | null;
72
- /**
73
- * As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).
74
- * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.
75
- */
76
- productName?: string | null;
77
- /**
78
- * The [electron-builder](https://www.electron.build/configuration/configuration) configuration.
79
- */
80
- builderConfig?: Configuration;
66
+ /**
67
+ * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as
68
+ * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.
69
+ * @default com.electron.${name}
70
+ */
71
+ appId?: string | null;
72
+ /**
73
+ * As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).
74
+ * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.
75
+ */
76
+ productName?: string | null;
77
+ /**
78
+ * The [electron-builder](https://www.electron.build/configuration/configuration) configuration.
79
+ */
80
+ builderConfig?: Configuration;
81
81
  }
82
82
  /**
83
83
  * vite plugin options
84
84
  */
85
85
  interface PluginOptions {
86
- /**
87
- * Recommended switch. Default is true.
88
- * if true, will have the following default behavior:
89
- * will change the main/preload/renderer outDir to be parallel outDir;
90
- * eg. if vite build.outDir is 'dist', will change main/preload/render to 'dist/main' and 'dist/preload' and 'dist/renderer'
91
- * @default true
92
- */
93
- recommended?: boolean;
94
- /**
95
- * Don't bundle these modules, but dependencies and peerDependencies in your package.json are always excluded. [See more](https://tsup.egoist.dev/#excluding-packages)
96
- * @see https://tsup.egoist.dev/#excluding-packages
97
- */
98
- external?: (string | RegExp)[];
99
- /**
100
- * electron main process options
101
- */
102
- main?: MainOptions;
103
- /**
104
- * electron preload process options
105
- */
106
- preload?: PreloadOptions;
107
- /**
108
- * When `recommended` and `builder.enable` are both `true`, use [electron-builder](https://www.electron.build) to package Electron applications.
109
- *
110
- * In the `build.outDir` directory configured in vite, generate a new package.json based on the configuration and package.json, excluding non-dependencies.
111
- * Execute `npm install` and then package.
112
- */
113
- builder?: boolean | BuilderOptions;
114
- /**
115
- * electron debug mode, don't startup electron. You can also use `process.env.VITE_ELECTRON_DEBUG`. Default is false.
116
- * @default false
117
- */
118
- debug?: boolean;
119
- /**
120
- * Electron will listen for V8 inspector protocol messages on the specified port, an external debugger will need to connect on this port.
121
- * You can also use `process.env.VITE_ELECTRON_INSPECT`. See [debugging-main-process](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process) for more information.
122
- * The default port is false.
123
- * @see https://www.electronjs.org/docs/latest/tutorial/debugging-main-process
124
- * @default false
125
- */
126
- inspect?: number | boolean;
86
+ /**
87
+ * Recommended switch. Default is true.
88
+ * if true, will have the following default behavior:
89
+ * will change the main/preload/renderer outDir to be parallel outDir;
90
+ * eg. if vite build.outDir is 'dist', will change main/preload/render to 'dist/main' and 'dist/preload' and 'dist/renderer'
91
+ * @default true
92
+ */
93
+ recommended?: boolean;
94
+ /**
95
+ * Don't bundle these modules, but dependencies and peerDependencies in your package.json are always excluded. [See more](https://tsup.egoist.dev/#excluding-packages)
96
+ * @see https://tsup.egoist.dev/#excluding-packages
97
+ */
98
+ external?: (string | RegExp)[];
99
+ /**
100
+ * electron main process options
101
+ */
102
+ main?: MainOptions;
103
+ /**
104
+ * electron preload process options
105
+ */
106
+ preload?: PreloadOptions;
107
+ /**
108
+ * When `recommended` and `builder.enable` are both `true`, use [electron-builder](https://www.electron.build) to package Electron applications.
109
+ *
110
+ * In the `build.outDir` directory configured in vite, generate a new package.json based on the configuration and package.json, excluding non-dependencies.
111
+ * Execute `npm install` and then package.
112
+ */
113
+ builder?: boolean | BuilderOptions;
114
+ /**
115
+ * electron debug mode, don't startup electron. You can also use `process.env.VITE_ELECTRON_DEBUG`. Default is false.
116
+ * @default false
117
+ */
118
+ debug?: boolean;
119
+ /**
120
+ * Electron will listen for V8 inspector protocol messages on the specified port, an external debugger will need to connect on this port.
121
+ * You can also use `process.env.VITE_ELECTRON_INSPECT`. See [debugging-main-process](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process) for more information.
122
+ * The default port is false.
123
+ * @see https://www.electronjs.org/docs/latest/tutorial/debugging-main-process
124
+ * @default false
125
+ */
126
+ inspect?: number | boolean;
127
127
  }
128
-
128
+ //#endregion
129
+ //#region src/index.d.ts
129
130
  /**
130
131
  * A simple vite plugin for electron
131
132
  * @param options
132
133
  */
133
134
  declare function useElectronPlugin(options?: PluginOptions): Plugin;
134
-
135
- export { type BuilderOptions, type MainOptions, type PluginOptions, type PreloadOptions, useElectronPlugin as default, useElectronPlugin };
135
+ //#endregion
136
+ export { BuilderOptions, MainOptions, PluginOptions, PreloadOptions, useElectronPlugin as default, useElectronPlugin };