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

Remove use of fs module #194

Merged
merged 8 commits into from Sep 28, 2022
Merged

Remove use of fs module #194

merged 8 commits into from Sep 28, 2022

Conversation

Madff386
Copy link
Contributor

From version 20.0.0 of electron, preload process is now sandboxed by default electron #32869

This causes titlebar to throw errors when attempting to fetch node fs module used to read the custom user provided icon json file.

Updated titlebar.ts to remove the import of fs module and directly pass a dictionary of the json file instead of reading it from disk.

Using a bundler like webpack for the preload.js script could work like this (not tested):

import { Titlebar, Color } from 'custom-electron-titlebar';
import icon from './assets/images/icon.svg';
import icons from './assets/icons.json';

let titlebar;

window.addEventListener('DOMContentLoaded', () => {
  titlebar = new Titlebar({
    backgroundColor: Color.fromHex("#388e3c"),
    itemBackgroundColor: Color.fromHex("#121212"),
    svgColor: Color.WHITE,
    icon: icon,
    icons: icons,
    //menu: null // = do not automatically use Menu.applicationMenu
  })

@Muhammad-Taif-Khan
Copy link

Did you test it?

@mdaff169
Copy link

I haven’t yet tested that example for the preload script. I can if you want me to.

@AlexTorresDev AlexTorresDev changed the base branch from master to develop September 28, 2022 13:32
@AlexTorresDev AlexTorresDev merged commit b857d51 into AlexTorresDev:develop Sep 28, 2022
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

Successfully merging this pull request may close these issues.

None yet

6 participants