Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BrowserWindow not a constructor #210

Open
sdetweil opened this issue Jan 19, 2025 · 0 comments
Open

BrowserWindow not a constructor #210

sdetweil opened this issue Jan 19, 2025 · 0 comments

Comments

@sdetweil
Copy link

sdetweil commented Jan 19, 2025

I have this visual calendar function, using electron, started in 2017, using remote
which opens images related to text values in calendar entries, and pongs them over the screen.
multiple images may be shown concurrently based on calendar entries. they never overlay each other

this is under an app using electron to display a single page web app
MagicMirror

I did the new npm install (step 1 of instructions)
this app starts with

  our npm start script line
     "start": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js",
     this process does NOT do a 'require' of electron, as it is INSIDE electron
 
    I do the require('@electron/remote/main').initialize();  at the start of electron.js )very first thing, step2 of instructions)

    ---no browser window is open yet
    it calls some extension initializers, (one of which is my code) 
       I call 
           const { BrowserWindow } = require("@electron/remote")   (step 3 from the instructions)
                  but I get an error on startup 
                      "@electron/remote" cannot be required in the browser process. Instead require("@electron/remote/main")
                      but we haven't opened a page yet, 
                      yes I am in the browser 'process', it runs everything
  
       I will use **new  BrowserWindow()** to create and load an image, which floats like pong above the single page web app.
       I changed my code to do 
                const { BrowserWindow } = require("@electron/remote/main")  (per the message)
       I added the require('@electron/remote/main').enable(viewerinfo.webContents) after the window is created, see below

LATER we open the browser window,  but the prior code is  running on sep thread events (timers). all before main window is opened

code to open single page web a

and I use these webPreferences in the electronOptions object
    webPreferences: {
      contextIsolation: false,
      nodeIntegration: true,
      nodeIntegrationInWorker: true
      //zoomFactor: config.zoom
    },
// Create the browser window.
	mainWindow = new BrowserWindow(electronOptions);
	mainWindow.loadURL(`${prefix}${address}:${port}`);

some eons later, cal entry causes need for images to be displayed
my call to new BrowserWindow()

									viewerinfo.window = new BrowserWindow({
										width: viewerinfo.config.width,
										height: viewerinfo.config.height,
										x: new_x+self.SCREEN_LEFT,
										y: new_y,
										alwaysOnTop: true,
										show:false,
										transparent: true,
										backgroundColor: "#000000",
										paintWhenInitiallyHidden:true,
										dx: 0,
										dy: 0,
										frame: false,
										skipTaskbar: true,
										//parent:self.SCREEN_PARENT
									})
									require('@electron/remote/main').enable(viewerinfo.webContents)

but now new fails.. not a constructor

help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant