@tomjs/vite-plugin-electron 1.3.5 → 1.3.6

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
@@ -185,7 +185,8 @@ export default defineConfig({
185
185
  | 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) |
186
186
  | main | [MainOptions](#MainOptions) | | Configuration options for the electron main process. |
187
187
  | preload | [PreloadOptions](#PreloadOptions) | | Configuration options for the electron preload process. |
188
- | debug | `boolean` | `false` | Electron debug mode, don't startup electron. |
188
+ | debug | `boolean` | `false` | Electron debug mode, don't startup electron. You can also use `process.env.APP_ELECTRON_DEBUG`. Default is false. |
189
+ | inspect | `boolean` | `false` | Electron will listen for V8 inspector protocol messages on the specified port, an external debugger will need to connect on this port. You can also use `process.env.APP_ELECTRON_INSPECT`. See [debugging-main-process](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process) for more information. |
189
190
 
190
191
  **Notice**
191
192
 
@@ -291,4 +292,11 @@ Run `Debug Main Process` through `vscode` to debug the main thread. For debuggin
291
292
 
292
293
  **Notice**
293
294
 
294
- Although `Electron v28` supports `esm`, there may be problems with `VSCode Debug` sourcemap support and breakpoints cannot work properly. In this case, you can consider using `cjs` mode.
295
+ Although `Electron v28` supports `esm`, there may be problems with `VSCode Debug` sourcemap support and breakpoints cannot work properly. In this case, you can use `cjs` mode or turn off `sourcemap`
296
+
297
+ ```ts
298
+ electron({
299
+ main: { sourcemap: false },
300
+ preload: { sourcemap: false },
301
+ });
302
+ ```
package/README.zh_CN.md CHANGED
@@ -186,7 +186,8 @@ export default defineConfig({
186
186
  | external | `string[]` | | 不打包这些模块,但是 `dependencies` and `peerDependencies` 默认排除,[详见](https://tsup.egoist.dev/#excluding-packages) |
187
187
  | main | [MainOptions](#MainOptions) | | electron main 进程选项 |
188
188
  | preload | [PreloadOptions](#PreloadOptions) | | electron preload 进程选项 |
189
- | debug | `boolean` | `false` | electron调试模式,不启动electron |
189
+ | debug | `boolean` | `false` | Electron调试模式,不启动Electron。 您还可以使用 `process.env.APP_ELECTRON_DEBUG` |
190
+ | inspect | `boolean` | `false` | Electron 将监听指定 port 上的 V8 调试协议消息, 外部调试器需要连接到此端口上。您还可以使用 `process.env.APP_ELECTRON_INSPECT`。 有关更多信息,请参阅[debugging-main-process](https://www.electronjs.org/zh/docs/latest/tutorial/debugging-main-process)。 |
190
191
 
191
192
  `recommended` 选项用于设置默认配置和行为,几乎可以达到零配置使用,默认为 `true` 。如果你要自定义配置,请设置它为`false`。以下默认的前提条件是使用推荐的 [项目结构](#目录结构)。
192
193
 
@@ -290,4 +291,11 @@ app.whenReady().then(() => {
290
291
 
291
292
  **说明**
292
293
 
293
- `Electron v28` 虽然支持了 `esm`,但是 `VSCode Debug` sourcemap支持可能有问题,断点无法正常工作,这时可以考虑使用 `cjs` 模式
294
+ `Electron v28` 虽然支持了 `esm`,但是 `VSCode Debug` sourcemap支持可能有问题,断点无法正常工作。这种情况可以使用 `cjs` 模式或关闭 `sourcemap`。
295
+
296
+ ```ts
297
+ electron({
298
+ main: { sourcemap: false },
299
+ preload: { sourcemap: false },
300
+ });
301
+ ```
package/dist/index.d.mts CHANGED
@@ -79,6 +79,14 @@ interface PluginOptions {
79
79
  * @default false
80
80
  */
81
81
  debug?: boolean;
82
+ /**
83
+ * Electron will listen for V8 inspector protocol messages on the specified port, an external debugger will need to connect on this port.
84
+ * You can also use `process.env.APP_ELECTRON_INSPECT`. See [debugging-main-process](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process) for more information.
85
+ * The default port is false.
86
+ * @see https://www.electronjs.org/docs/latest/tutorial/debugging-main-process
87
+ * @default false
88
+ */
89
+ inspect?: number | boolean;
82
90
  }
83
91
 
84
92
  declare function vitePluginElectron(options?: PluginOptions): Plugin;
package/dist/index.d.ts CHANGED
@@ -79,6 +79,14 @@ interface PluginOptions {
79
79
  * @default false
80
80
  */
81
81
  debug?: boolean;
82
+ /**
83
+ * Electron will listen for V8 inspector protocol messages on the specified port, an external debugger will need to connect on this port.
84
+ * You can also use `process.env.APP_ELECTRON_INSPECT`. See [debugging-main-process](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process) for more information.
85
+ * The default port is false.
86
+ * @see https://www.electronjs.org/docs/latest/tutorial/debugging-main-process
87
+ * @default false
88
+ */
89
+ inspect?: number | boolean;
82
90
  }
83
91
 
84
92
  declare function vitePluginElectron(options?: PluginOptions): Plugin;
package/dist/index.js CHANGED
@@ -75,7 +75,15 @@ async function startup(options) {
75
75
  return;
76
76
  }
77
77
  await startup.exit();
78
- process.electronApp = _child_process.spawn.call(void 0, _electron2.default, ["."], {
78
+ const args = ["."];
79
+ if (options.inspect) {
80
+ if (typeof options.inspect === "number") {
81
+ args.push(`--inspect=${options.inspect}`);
82
+ } else {
83
+ args.push(`--inspect`);
84
+ }
85
+ }
86
+ process.electronApp = _child_process.spawn.call(void 0, _electron2.default, args, {
79
87
  stdio: "inherit"
80
88
  });
81
89
  process.electronApp.once("exit", process.exit);
@@ -151,6 +159,7 @@ function readJson(path2) {
151
159
  }
152
160
 
153
161
  // src/index.ts
162
+ var isDev = process.env.NODE_ENV === "development";
154
163
  function getPkg() {
155
164
  const pkgFile = _path2.default.resolve(process.cwd(), "package.json");
156
165
  if (!_fs2.default.existsSync(pkgFile)) {
@@ -208,9 +217,18 @@ function preMergeOptions(options) {
208
217
  });
209
218
  return opts;
210
219
  }
220
+ function geNumberBooleanValue(value) {
221
+ if (typeof value !== "string") {
222
+ return;
223
+ }
224
+ if (["true", "false"].includes(value)) {
225
+ return value === "true";
226
+ }
227
+ const v = Number(value);
228
+ return Number.isNaN(v) ? void 0 : v;
229
+ }
211
230
  function vitePluginElectron(options) {
212
231
  const opts = preMergeOptions(options);
213
- const isDev = process.env.NODE_ENV === "development";
214
232
  let isServer = false;
215
233
  return {
216
234
  name: PLUGIN_NAME,
@@ -253,6 +271,7 @@ function vitePluginElectron(options) {
253
271
  },
254
272
  configResolved(config) {
255
273
  opts.debug = config.env.APP_ELECTRON_DEBUG ? !!config.env.APP_ELECTRON_DEBUG : opts.debug;
274
+ opts.inspect = config.env.APP_ELECTRON_INSPECT ? geNumberBooleanValue(config.env.APP_ELECTRON_INSPECT) : opts.inspect;
256
275
  },
257
276
  configureServer(server) {
258
277
  if (!server || !server.httpServer) {
package/dist/index.mjs CHANGED
@@ -75,7 +75,15 @@ async function startup(options) {
75
75
  return;
76
76
  }
77
77
  await startup.exit();
78
- process.electronApp = spawn(electron, ["."], {
78
+ const args = ["."];
79
+ if (options.inspect) {
80
+ if (typeof options.inspect === "number") {
81
+ args.push(`--inspect=${options.inspect}`);
82
+ } else {
83
+ args.push(`--inspect`);
84
+ }
85
+ }
86
+ process.electronApp = spawn(electron, args, {
79
87
  stdio: "inherit"
80
88
  });
81
89
  process.electronApp.once("exit", process.exit);
@@ -150,6 +158,7 @@ function readJson(path2) {
150
158
  }
151
159
 
152
160
  // src/index.ts
161
+ var isDev = process.env.NODE_ENV === "development";
153
162
  function getPkg() {
154
163
  const pkgFile = path.resolve(process.cwd(), "package.json");
155
164
  if (!fs2.existsSync(pkgFile)) {
@@ -207,9 +216,18 @@ function preMergeOptions(options) {
207
216
  });
208
217
  return opts;
209
218
  }
219
+ function geNumberBooleanValue(value) {
220
+ if (typeof value !== "string") {
221
+ return;
222
+ }
223
+ if (["true", "false"].includes(value)) {
224
+ return value === "true";
225
+ }
226
+ const v = Number(value);
227
+ return Number.isNaN(v) ? void 0 : v;
228
+ }
210
229
  function vitePluginElectron(options) {
211
230
  const opts = preMergeOptions(options);
212
- const isDev = process.env.NODE_ENV === "development";
213
231
  let isServer = false;
214
232
  return {
215
233
  name: PLUGIN_NAME,
@@ -252,6 +270,7 @@ function vitePluginElectron(options) {
252
270
  },
253
271
  configResolved(config) {
254
272
  opts.debug = config.env.APP_ELECTRON_DEBUG ? !!config.env.APP_ELECTRON_DEBUG : opts.debug;
273
+ opts.inspect = config.env.APP_ELECTRON_INSPECT ? geNumberBooleanValue(config.env.APP_ELECTRON_INSPECT) : opts.inspect;
255
274
  },
256
275
  configureServer(server) {
257
276
  if (!server || !server.httpServer) {
package/env.d.ts CHANGED
@@ -17,5 +17,9 @@ declare namespace NodeJS {
17
17
  * Electron main process debug, don't startup electron
18
18
  */
19
19
  APP_ELECTRON_DEBUG?: string;
20
+ /**
21
+ * Electron will listen for V8 inspector protocol messages on the specified port, an external debugger will need to connect on this port. The default port is 5858.
22
+ */
23
+ APP_ELECTRON_INSPECT?: string;
20
24
  }
21
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomjs/vite-plugin-electron",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "A simple vite plugin for electron, supports esm/cjs, support esm in electron v28+",
5
5
  "keywords": [
6
6
  "vite",