tnp-core 19.0.51 → 19.0.52

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.
@@ -2377,28 +2377,19 @@ var UtilsOs;
2377
2377
  * Electron backend or browser.
2378
2378
  */
2379
2379
  UtilsOs.isRunningInElectron = () => {
2380
- if (UtilsOs.isRunningInSSRMode()) {
2381
- return false; // no ssr for electron
2382
- }
2383
- // Renderer process
2384
- // @ts-ignore
2385
- if (typeof window !== 'undefined' &&
2386
- typeof window.process === 'object' &&
2387
- // @ts-ignore
2388
- window.process.type === 'renderer') {
2380
+ // Electron main or renderer (most reliable)
2381
+ if (typeof process !== 'undefined' && process?.versions?.electron) {
2389
2382
  return true;
2390
2383
  }
2391
- // Main process
2392
- // @ts-ignore
2393
- if (typeof process !== 'undefined' &&
2394
- typeof process.versions === 'object' &&
2395
- !!process.versions.electron) {
2384
+ // Renderer with nodeIntegration
2385
+ if (typeof globalThis !== 'undefined' &&
2386
+ globalThis?.process?.type === 'renderer') {
2396
2387
  return true;
2397
2388
  }
2398
- // Detect the user agent when the `nodeIntegration` option is set to false
2389
+ // Renderer with nodeIntegration disabled
2399
2390
  if (typeof navigator === 'object' &&
2400
2391
  typeof navigator.userAgent === 'string' &&
2401
- navigator.userAgent.indexOf('Electron') >= 0) {
2392
+ /Electron/i.test(navigator.userAgent)) {
2402
2393
  return true;
2403
2394
  }
2404
2395
  return false;