Quasar: [Electron] global.__statics and ‘ready’ event issues in Electron mode

Created on 21 Dec 2019  ·  4Comments  ·  Source: quasarframework/quasar

Describe the bug
__statics is OK global.__statics is undefined
The ‘ready’ event cannot be fired after 'quasar dev -m electron'

Codepen/jsFiddle/Codesandbox (required)
Electron issue

To Reproduce
Steps to reproduce the behavior:

  1. in electron-main.js
if (process.env.PROD) {
  global.__statics = require('path').join(__dirname, 'statics').replace(/\\/g, '\\\\')
} else {
  console.log(global)
  console.log(__statics)
}
  1. quasar dev -m electron

Expected behavior
global.__statics and should be set and 'ready' event should be fired.

Screenshots

Object [global] {
  global: [Circular],
  clearInterval: [Function: clearInterval],
  clearTimeout: [Function: clearTimeout],
  setInterval: [Function],
  setTimeout: [Function] { [Symbol(util.promisify.custom)]: [Function] },
  queueMicrotask: [Function: queueMicrotask],
  clearImmediate: [Function: clearImmediate],
  setImmediate: [Function] { [Symbol(util.promisify.custom)]: [Function] },
  '__core-js_shared__': {
    versions: [ [Object], [Object] ],
    wks: {
      toStringTag: Symbol(Symbol.toStringTag),
      species: Symbol(Symbol.species),
      replace: Symbol(Symbol.replace),
      iterator: Symbol(Symbol.iterator),
      _hidden: Symbol(Symbol._hidden),
      toPrimitive: Symbol(Symbol.toPrimitive),
      hasInstance: Symbol(Symbol.hasInstance),
      isConcatSpreadable: Symbol(Symbol.isConcatSpreadable),
      match: Symbol(Symbol.match),
      search: Symbol(Symbol.search),
      split: Symbol(Symbol.split),
      unscopables: Symbol(Symbol.unscopables),
      asyncIterator: Symbol(Symbol.asyncIterator),
      observable: Symbol(Symbol.observable)
    },
    'native-function-to-string': [Function: toString],
    keys: { IE_PROTO: 'Symbol(IE_PROTO)_1.xmdr1hw6d8' },
    'symbol-registry': {},
    symbols: {},
    'op-symbols': {}
  },
  core: {
    version: '2.6.11',
    inspectSource: [Function],
    '[object Object]': { prototype: {} },
    Object: { prototype: {} },
    prototype: {},
    JSON: { prototype: {} },
    Array: { prototype: [Object] },
    getIteratorMethod: [Function],
    String: { prototype: [Object] }
  }
}
C:\Users\huget\WebstormProjects\downloadbox\src\statics

Platform (please complete the following information):
quasar info

Operating System - Windows_NT(10.0.18362) - win32/x64
NodeJs - 12.12.0

Global packages
  NPM - 6.11.3
  yarn - 1.21.1
  @quasar/cli - 1.0.5
  cordova - Not installed

Important local packages
  quasar - 1.5.10 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app - 1.4.3 -- Quasar Framework local CLI
  @quasar/extras - 1.3.3 -- Quasar Framework fonts, icons and animations
  vue - 2.6.11 -- Reactive, component-oriented view layer for modern web interfaces.
  vue-router - 3.1.3 -- Official router for Vue.js 2
  vuex - 3.1.2 -- state management for Vue.js
  electron - 6.1.7 -- Build cross platform desktop apps with JavaScript, HTML, and CSS
  electron-packager - Not installed
  electron-builder - 21.2.0 -- A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out of the box
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed
  @babel/core - 7.7.7 -- Babel compiler core.
  webpack - 4.41.3 -- Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  webpack-dev-server - 3.9.0 -- Serves a webpack app. Updates the browser on changes.
  workbox-webpack-plugin - 4.3.1 -- A plugin for your Webpack build process, helping you generate a manifest of local files that workbox-sw should precache.
  register-service-worker - 1.6.2 -- Script for registering service worker, with hooks

Quasar App Extensions
  *None installed*

Networking
  Host - DESKTOP-FKIU25H
  Ethernet - 192.168.31.134
  VirtualBox Host-Only Network - 169.254.124.40
  VirtualBox Host-Only Network #2 - 169.254.109.233

bug

Most helpful comment

Hi All,

To summarize: this is NOT a bug with Quasar. It is outside of our reach to fix the root cause since the bug is in vue-devtools' code.

Workaround: in your /src-electron/main-process/electron-main.js change:

import { app, BrowserWindow } from 'electron'

to this:

import { app, BrowserWindow, nativeTheme } from 'electron'

try {
  if (process.platform === 'win32' && nativeTheme.shouldUseDarkColors === true) {
    require('fs').unlinkSync(require('path').join(app.getPath('userData'), 'DevTools Extensions'))
  }
} catch (_) { }

This has also been added to docs (will be available on next docs deployment).

All 4 comments

'ready' event in electron-quick-start can be fired properly

Electron5 is ok Electron6,7 has this issue

Ok, I found the issue: something in Vue Dev Tools is not very compatible with electron 6 and 7 on Windows 10 in Dark mode.

refs:

The simplest workaround:

in src-electron\main-process\electron-main.dev.js replace

// Install `vue-devtools`
require('electron').app.on('ready', () => {

with:

// Install `vue-devtools`
const app = require('electron').app

app.removeAllListeners('ready')
app.on('ready', () => {

:) or temporary disable dark mode

Hi All,

To summarize: this is NOT a bug with Quasar. It is outside of our reach to fix the root cause since the bug is in vue-devtools' code.

Workaround: in your /src-electron/main-process/electron-main.js change:

import { app, BrowserWindow } from 'electron'

to this:

import { app, BrowserWindow, nativeTheme } from 'electron'

try {
  if (process.platform === 'win32' && nativeTheme.shouldUseDarkColors === true) {
    require('fs').unlinkSync(require('path').join(app.getPath('userData'), 'DevTools Extensions'))
  }
} catch (_) { }

This has also been added to docs (will be available on next docs deployment).

Was this page helpful?
0 / 5 - 0 ratings