SlideShare a Scribd company logo
 
Linux, Windows, MacOS?
One framework to rule them all!
Firenze, 2020-01-28
Denny Biasiolli
WHO AM IWHO AM I
Denny Biasiolli
Software Developer @ Sequar Srl, Cherasco (CN)
   @dennybiasiolli   
denny.biasiolli@gmail.com
dennybiasiolli.com
CONS OF DESKTOP APPLICATIONSCONS OF DESKTOP APPLICATIONS
Developing desktop applications can be full of
challenges that make it dif cult to approach.
Packaging installation
Managing updates
Design of the application
Translate design for different operating systems
Use of native features (menus, noti cations)
PROS OF WEB APPLICATIONSPROS OF WEB APPLICATIONS
Everybody has a web browser installed
Modern browsers come loaded with powerful
debugging tools
Universal cross-platform languages (HTML, CSS, JS)
Huge support communities behind them
Countless libraries, frameworks and components
you can take advantage of
(Bootstrap, jQuery, Angular, React, Vue.js, ...)
CONS OF WEB APPLICATIONSCONS OF WEB APPLICATIONS
Conditional rules for dozens of different browser
versions
Limited interaction with the le system
Performances based on network connection
Can be more painful than writing code for different
operating systems
<--[if IE]>
--webkit-border-radius
navigator.userAgent
INTRODUCINGINTRODUCING
Electron is a framework that lets you create cross-
platform applications using HTML, Javascript and CSS.
INTRODUCING ELECTRONINTRODUCING ELECTRON
Minimal web browser with the ability to interact
with the local le system
This web browser is part of your applications
packaging
Everyone using your app is running it under the same
set of conditions.
Rich JavaScript APIs that handle the particulars of
talking to different operating systems
Webpages for creating user interfaces
ELECTRON IS CROSS PLATFORMELECTRON IS CROSS PLATFORM
You can write your application once and have it run
on Mac, Windows or Linux
Electron serves as a universal interface with the
operating system
You can focus on what your app should do,
Electron manages the how for you.
ELECTRON IS CROSS PLATFORMELECTRON IS CROSS PLATFORM
Core set of APIs
Chromium APIs
All Node.js built in modules
Third party modules
USE IT EVERYWHEREUSE IT EVERYWHERE
Electron is an open source project, but that doesn't
mean you have to use it for open source software.
People ranging from hobbyists to professionals are
adopting Electron as their tool for building modern
desktop applications.
In fact you may already be using software built on
Electron and not even knew it.
ELECTRON APPSELECTRON APPS
                   
                   
More on https://electronjs.org/apps
(Electron website)
“Electron is a framework for creating
native applications with web
technologies like JavaScript, HTML, and
CSS. It takes care of the hard parts so you
can focus on the core of your application.”
(Electron website)
“Electron is a framework for creating
native applications with web
technologies like JavaScript, HTML, and
CSS. It takes care of the hard parts so you
can focus on the core of your application.”
“It's easier than you think”
(Electron website)
“Electron is a framework for creating
native applications with web
technologies like JavaScript, HTML, and
CSS. It takes care of the hard parts so you
can focus on the core of your application.”
“It's easier than you think”
“If you can build a website, you can build
a desktop app.”
2007, Jeff Atwood, Author, Entrepreneur, Cofounder of StackOver ow
“Any application that can be written in
JavaScript, will eventually be written in
JavaScript.”
2007, Jeff Atwood, Author, Entrepreneur, Cofounder of StackOver ow
1982, Edward A. Murphy
“Any application that can be written in
JavaScript, will eventually be written in
JavaScript.”
“If anything can go wrong, it will.”
ROADMAPROADMAP
Gets a web app
Installing Electron
Using Electron with the app
Packaging the app
Yay! o/
WEBSITE STRUCTUREWEBSITE STRUCTURE
.
+-- www/
+-- css/
| +-- style.css
|
+-- js/
| +-- script.js
|
+-- index.html
+-- page1.html
+-- ...
CONFIGURING PACKAGECONFIGURING PACKAGE
package.jsonpackage.json
{
"name": "electron_sample_2020",
"version": "0.1.0",
"main": "electron/main.js"
}
INSTALLING ELECTRONINSTALLING ELECTRON
# globally
npm install -g electron
# or
# local dependency
npm install --save-dev electron
CONFIGURING ELECTRONCONFIGURING ELECTRON
electron/main.jselectron/main.js
const { app, BrowserWindow } = require('electron')
function createWindow () {
let win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('www/index.html')
}
app.on('ready', createWindow)
CONFIGURING ELECTRONCONFIGURING ELECTRON
electron/main.js advancedelectron/main.js advanced
const { app, BrowserWindow } = require('electron')
// Keep a global reference of the window object, if you don't
// the window will be closed automatically when the JavaScript
// object is garbage collected.
let win
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
LAUNCHING ELECTRONLAUNCHING ELECTRON
package.jsonpackage.json
"scripts": {
"start": "electron ."
}
# npm launch
npm run start
# or
# global installation
electron .
# or
# local installation
npx electron .
PACKAGINGPACKAGING
create asar archive
copy archive in electron folder
rename electron
con gure icon
compile
ecc...
INSTALLING ELECTRON-BUILDERINSTALLING ELECTRON-BUILDER
package.jsonpackage.json
# globally
npm install -g electron-builder
# use with `electron-builder`
# or
# local dependency
npm install --save-dev electron-builder
# use with `npx electron-builder`
"scripts": {
"dist": "electron-builder -mwl",
"pack": "electron-builder -mwl --dir"
},
CONFIGURING ELECTRON-BUILDERCONFIGURING ELECTRON-BUILDER
electron-builder.ymlelectron-builder.yml
appId: electron.sample.2020
productName: Electron Sample 2020
copyright: Copyright © 2020 ${author}
icon: icons/icon.png
files:
- electron/**/*
- www/**/*
mac:
category: public.app-category.utilities
CONFIGURING ELECTRON-BUILDERCONFIGURING ELECTRON-BUILDER
electron-builder.ymlelectron-builder.yml
# ...
mac:
category: public.app-category.utilities
target: dmg
win:
target: nsis
linux:
target: AppImage
USING ELECTRON-BUILDERUSING ELECTRON-BUILDER
BUT WAITBUT WAIT
On Linux and Windows you cannot sign macOS apps
On Linux and Windows you cannot build DMG archive for macOS
npm run pack
# electron-builder -mwl --dir
# or
npm run dist
# electron-builder -mwl
skipped macOS application code signing reason=supported only on macOS
TIP: LINKSTIP: LINKS
// electron/main.js
const { shell } = require('electron')
// ...
// open new-window externally
app.on('ready', () => {
win.webContents.on('new-window', (e, url) => {
e.preventDefault()
shell.openExternal(url)
})
})
TIP: WEB TOOLSTIP: WEB TOOLS
How to disable web tools in production?
// electron/main.js
// ...
win = new BrowserWindow({
// ...
webPreferences: {
devTools: false,
// ...
}
// ...
})
TIP: NOTIFICATIONSTIP: NOTIFICATIONS
// www/js/script.js
const btnNotification = document.getElementById('btnNotification'
btnNotification.onclick = () => {
const myNotification = new Notification('Title', {
body: 'Lorem Ipsum Dolor Sit Amet'
})
myNotification.onclick = () => {
console.log('Notification clicked')
}
}
TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION
SyncSync
// electron/main.js
const { ipcMain } = require('electron')
ipcMain.on('synchronous-message', (event, arg) => {
console.log(arg)
setTimeout(() => {
event.returnValue = 'pong sync'
}, 1000)
})
TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION
SyncSync
// www/js/script.js
const { ipcRenderer } = require('electron')
const btnIpcSync = document.getElementById('btnIpcSync')
btnIpcSync.onclick = () => {
console.log(
ipcRenderer.sendSync('synchronous-message', 'ping sync')
)
}
TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION
AsyncAsync
// electron/main.js
const { ipcMain } = require('electron')
ipcMain.on('asynchronous-message', (event, arg) => {
console.log(arg)
setTimeout(() => {
event.reply('asynchronous-reply', 'pong async')
}, 1000)
})
TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION
AsyncAsync
// www/js/script.js
const { ipcRenderer } = require('electron')
ipcRenderer.on('asynchronous-reply', (event, arg) => {
console.log(arg)
})
const btnIpcAsync = document.getElementById('btnIpcAsync')
btnIpcAsync.onclick = () => {
ipcRenderer.send('asynchronous-message', 'ping async')
}
TIP: PROGRESS BARTIP: PROGRESS BAR
Setting the parameter to a value below zero (like -1)
will remove the progress bar while setting it to a value
higher than one (like 2) will switch the progress bar to
intermediate mode.
// electron/main.js
win.setProgressBar(value)
TIP: PROGRESS BARTIP: PROGRESS BAR
// electron/main.js
const { ipcMain } = require('electron')
ipcMain.on('test-progress-bar', (event, arg) => {
let progressVal = 0
const interval = setInterval(() => {
progressVal += 1
win.setProgressBar(progressVal / 100)
if (progressVal == 100) {
clearInterval(interval)
win.setProgressBar(-1)
event.reply('test-progress-bar-reply')
}
}, 100)
})
TIP: PROGRESS BARTIP: PROGRESS BAR
// www/js/script.js
const { ipcRenderer } = require('electron')
ipcRenderer.on('test-progress-bar-reply', () => {
new Notification('Progress completed', {
body: 'All progress are completed'
})
})
const btnIpcProgress = document.getElementById('btnIpcProgress')
btnIpcProgress.onclick = () => {
ipcRenderer.send('test-progress-bar')
}
TIP: CREATE-REACT-APP COMPATIBILITYTIP: CREATE-REACT-APP COMPATIBILITY
Adding electron-builder to a create-react-app project
could be very painful.
⨯ Application entry file "build/electron.js" in the
"path/repo/dist/mac/My.app/Contents/Resources/app.asar"
does not exist. Seems like a wrong configuration.
TIP: CREATE-REACT-APP COMPATIBILITYTIP: CREATE-REACT-APP COMPATIBILITY
Fix:Fix: http://tiny.cc/5jxyizhttp://tiny.cc/5jxyiz
# use yarn
yarn install --dev electron
yarn install --dev electron-builder
yarn run ...
// add `homepage` in `package.json`
"homepage": "./",
# move `electron/main.js` in `public` folder
electron/main.js => public/electron.js
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
Auto-updatable Targets
macOS: DMG
macOS application must be signed in order for auto
updating to work
Linux: AppImage
Windows: NSIS
https://www.electron.build/auto-updatehttps://www.electron.build/auto-update
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
ConfigurationConfiguration
1. Install electron-updater as an app dependency.
2. Con gure publish in electron-builder.yml.
npm install --save electron-updater
publish:
provider: generic
url: https://your.release.website/release_path/
mac:
target: [dmg, zip] # add zip, important!
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
Configuration (electron/main.js)Configuration (electron/main.js)
3. Use autoUpdater from electron-updater instead of
electron:
4. Call update function
const { autoUpdater } = require('electron-updater')
app.on('ready', () => {
setTimeout(() => {
autoUpdater.checkForUpdatesAndNotify()
}, 1000)
})
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
NotificationsNotifications
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
Advanced usageAdvanced usage
// www/js/script.js
const { ipcRenderer } = require('electron')
ipcRenderer.on('update-message', function (event, { body, timeout
const notification = new Notification('AutoUpdate', {
body
})
setTimeout(() => {
notification.close()
}, timeout)
})
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
Advanced usageAdvanced usage
// electron/main.js
function sendStatusToWindow(text, timeout = 20000) {
win.webContents.send('update-message', {
body: text,
timeout,
})
}
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
Advanced usageAdvanced usage
// electron/main.js
autoUpdater.on('checking-for-update', () => {
sendStatusToWindow('Checking for update...')
})
autoUpdater.on('update-available', (info) => {
sendStatusToWindow('Update available.')
})
autoUpdater.on('update-not-available', (info) => {
sendStatusToWindow('Update not available.')
})
TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP
Advanced usageAdvanced usage
// electron/main.js
autoUpdater.on('error', (err) => {
sendStatusToWindow('Error in auto-updater. ' + err)
})
autoUpdater.on('download-progress', (progressObj) => {
let log_message = "Download speed: " + progressObj.bytesPerSeco
log_message = log_message + ' - Downloaded ' + progressObj.perc
log_message = log_message + ' (' + progressObj.transferred + "/
sendStatusToWindow(log_message)
})
autoUpdater.on('update-downloaded', (info) => {
sendStatusToWindow('Update downloaded')
})
LINKSLINKS
Slides:
   @dennybiasiolli   
electronjs.org
electron.build
github.com/dennybiasiolli/electron_sample_2020
github.com/dennybiasiolli/bingo-extract
slideshare.net/DennyBiasiolli
denny.biasiolli@gmail.com
dennybiasiolli.com

More Related Content

What's hot

Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
TrevorBurnham
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKHow to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
Dominik Renzel
 
Js Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform betterJs Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform better
Ivo Andreev
 
WebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.jsWebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.js
Robert Nyman
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
Aravindharamanan S
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...
RIA RUI Society
 

What's hot (7)

Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKHow to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
 
Js Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform betterJs Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform better
 
WebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.jsWebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.js
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...
 

Similar to Electron: Linux, Windows or Macos?

Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
Ulrich Krause
 
Bringing Javascript to the Desktop with Electron
Bringing Javascript to the Desktop with ElectronBringing Javascript to the Desktop with Electron
Bringing Javascript to the Desktop with Electron
Nir Noy
 
Building Cross Platform Apps with Electron
Building Cross Platform Apps with ElectronBuilding Cross Platform Apps with Electron
Building Cross Platform Apps with Electron
Chris Ward
 
Electron
ElectronElectron
Electron
Jens Siebert
 
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
Sencha
 
Electron
ElectronElectron
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global domination
Stfalcon Meetups
 
Frontend. Global domination.
Frontend. Global domination.Frontend. Global domination.
Frontend. Global domination.
Андрей Вандакуров
 
Get that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and ElectronGet that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and Electron
Lukas Ruebbelke
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
Simon Willison
 
Electron
ElectronElectron
Tutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJSTutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJS
Philipp Burgmer
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
Matteo Manchi
 
Going Desktop with Electron
Going Desktop with ElectronGoing Desktop with Electron
Going Desktop with Electron
Leo Lindhorst
 
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSMeteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Julio Antonio Mendonça de Marins
 
Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!
*instinctools
 
Pivorak.javascript.global domination
Pivorak.javascript.global dominationPivorak.javascript.global domination
Pivorak.javascript.global domination
Андрей Вандакуров
 
Andriy Vandakurov about "Frontend. Global domination"
Andriy Vandakurov about  "Frontend. Global domination" Andriy Vandakurov about  "Frontend. Global domination"
Andriy Vandakurov about "Frontend. Global domination"
Pivorak MeetUp
 
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and AngularNativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
Todd Anglin
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
Dalibor Gogic
 

Similar to Electron: Linux, Windows or Macos? (20)

Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
 
Bringing Javascript to the Desktop with Electron
Bringing Javascript to the Desktop with ElectronBringing Javascript to the Desktop with Electron
Bringing Javascript to the Desktop with Electron
 
Building Cross Platform Apps with Electron
Building Cross Platform Apps with ElectronBuilding Cross Platform Apps with Electron
Building Cross Platform Apps with Electron
 
Electron
ElectronElectron
Electron
 
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
 
Electron
ElectronElectron
Electron
 
Front-end. Global domination
Front-end. Global dominationFront-end. Global domination
Front-end. Global domination
 
Frontend. Global domination.
Frontend. Global domination.Frontend. Global domination.
Frontend. Global domination.
 
Get that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and ElectronGet that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and Electron
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
 
Electron
ElectronElectron
Electron
 
Tutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJSTutorial: Develop Mobile Applications with AngularJS
Tutorial: Develop Mobile Applications with AngularJS
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
Going Desktop with Electron
Going Desktop with ElectronGoing Desktop with Electron
Going Desktop with Electron
 
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJSMeteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
Meteoro de pegasuus! Desenvolvendo aplicações realtime com MeteorJS
 
Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!
 
Pivorak.javascript.global domination
Pivorak.javascript.global dominationPivorak.javascript.global domination
Pivorak.javascript.global domination
 
Andriy Vandakurov about "Frontend. Global domination"
Andriy Vandakurov about  "Frontend. Global domination" Andriy Vandakurov about  "Frontend. Global domination"
Andriy Vandakurov about "Frontend. Global domination"
 
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and AngularNativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 

More from Commit University

Alla scoperta dei Vector Database e dei RAG
Alla scoperta dei Vector Database e dei RAGAlla scoperta dei Vector Database e dei RAG
Alla scoperta dei Vector Database e dei RAG
Commit University
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Commit University
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Commit University
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Commit University
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Commit University
 
Slide-10years.pdf
Slide-10years.pdfSlide-10years.pdf
Slide-10years.pdf
Commit University
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Commit University
 
Vue.js slots.pdf
Vue.js slots.pdfVue.js slots.pdf
Vue.js slots.pdf
Commit University
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptx
Commit University
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PA
Commit University
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Commit University
 
Prisma the ORM that node was waiting for
Prisma the ORM that node was waiting forPrisma the ORM that node was waiting for
Prisma the ORM that node was waiting for
Commit University
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit University
Commit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdf
Commit University
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Commit University
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step Functions
Commit University
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and Swift
Commit University
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazione
Commit University
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lc
Commit University
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-Code
Commit University
 

More from Commit University (20)

Alla scoperta dei Vector Database e dei RAG
Alla scoperta dei Vector Database e dei RAGAlla scoperta dei Vector Database e dei RAG
Alla scoperta dei Vector Database e dei RAG
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
 
Slide-10years.pdf
Slide-10years.pdfSlide-10years.pdf
Slide-10years.pdf
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
 
Vue.js slots.pdf
Vue.js slots.pdfVue.js slots.pdf
Vue.js slots.pdf
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptx
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PA
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
 
Prisma the ORM that node was waiting for
Prisma the ORM that node was waiting forPrisma the ORM that node was waiting for
Prisma the ORM that node was waiting for
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdf
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step Functions
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and Swift
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazione
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lc
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-Code
 

Recently uploaded

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 

Recently uploaded (20)

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 

Electron: Linux, Windows or Macos?

  • 1.   Linux, Windows, MacOS? One framework to rule them all! Firenze, 2020-01-28 Denny Biasiolli
  • 2. WHO AM IWHO AM I Denny Biasiolli Software Developer @ Sequar Srl, Cherasco (CN)    @dennybiasiolli    denny.biasiolli@gmail.com dennybiasiolli.com
  • 3. CONS OF DESKTOP APPLICATIONSCONS OF DESKTOP APPLICATIONS Developing desktop applications can be full of challenges that make it dif cult to approach. Packaging installation Managing updates Design of the application Translate design for different operating systems Use of native features (menus, noti cations)
  • 4. PROS OF WEB APPLICATIONSPROS OF WEB APPLICATIONS Everybody has a web browser installed Modern browsers come loaded with powerful debugging tools Universal cross-platform languages (HTML, CSS, JS) Huge support communities behind them Countless libraries, frameworks and components you can take advantage of (Bootstrap, jQuery, Angular, React, Vue.js, ...)
  • 5. CONS OF WEB APPLICATIONSCONS OF WEB APPLICATIONS Conditional rules for dozens of different browser versions Limited interaction with the le system Performances based on network connection Can be more painful than writing code for different operating systems <--[if IE]> --webkit-border-radius navigator.userAgent
  • 6. INTRODUCINGINTRODUCING Electron is a framework that lets you create cross- platform applications using HTML, Javascript and CSS.
  • 7. INTRODUCING ELECTRONINTRODUCING ELECTRON Minimal web browser with the ability to interact with the local le system This web browser is part of your applications packaging Everyone using your app is running it under the same set of conditions. Rich JavaScript APIs that handle the particulars of talking to different operating systems Webpages for creating user interfaces
  • 8. ELECTRON IS CROSS PLATFORMELECTRON IS CROSS PLATFORM You can write your application once and have it run on Mac, Windows or Linux Electron serves as a universal interface with the operating system You can focus on what your app should do, Electron manages the how for you.
  • 9. ELECTRON IS CROSS PLATFORMELECTRON IS CROSS PLATFORM Core set of APIs Chromium APIs All Node.js built in modules Third party modules
  • 10. USE IT EVERYWHEREUSE IT EVERYWHERE Electron is an open source project, but that doesn't mean you have to use it for open source software. People ranging from hobbyists to professionals are adopting Electron as their tool for building modern desktop applications. In fact you may already be using software built on Electron and not even knew it.
  • 11. ELECTRON APPSELECTRON APPS                                         More on https://electronjs.org/apps
  • 12. (Electron website) “Electron is a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It takes care of the hard parts so you can focus on the core of your application.”
  • 13. (Electron website) “Electron is a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It takes care of the hard parts so you can focus on the core of your application.” “It's easier than you think”
  • 14. (Electron website) “Electron is a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It takes care of the hard parts so you can focus on the core of your application.” “It's easier than you think” “If you can build a website, you can build a desktop app.”
  • 15. 2007, Jeff Atwood, Author, Entrepreneur, Cofounder of StackOver ow “Any application that can be written in JavaScript, will eventually be written in JavaScript.”
  • 16. 2007, Jeff Atwood, Author, Entrepreneur, Cofounder of StackOver ow 1982, Edward A. Murphy “Any application that can be written in JavaScript, will eventually be written in JavaScript.” “If anything can go wrong, it will.”
  • 17. ROADMAPROADMAP Gets a web app Installing Electron Using Electron with the app Packaging the app Yay! o/
  • 18. WEBSITE STRUCTUREWEBSITE STRUCTURE . +-- www/ +-- css/ | +-- style.css | +-- js/ | +-- script.js | +-- index.html +-- page1.html +-- ...
  • 19. CONFIGURING PACKAGECONFIGURING PACKAGE package.jsonpackage.json { "name": "electron_sample_2020", "version": "0.1.0", "main": "electron/main.js" }
  • 20. INSTALLING ELECTRONINSTALLING ELECTRON # globally npm install -g electron # or # local dependency npm install --save-dev electron
  • 21. CONFIGURING ELECTRONCONFIGURING ELECTRON electron/main.jselectron/main.js const { app, BrowserWindow } = require('electron') function createWindow () { let win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } }) win.loadFile('www/index.html') } app.on('ready', createWindow)
  • 22. CONFIGURING ELECTRONCONFIGURING ELECTRON electron/main.js advancedelectron/main.js advanced const { app, BrowserWindow } = require('electron') // Keep a global reference of the window object, if you don't // the window will be closed automatically when the JavaScript // object is garbage collected. let win function createWindow () { // Create the browser window. win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } })
  • 23. LAUNCHING ELECTRONLAUNCHING ELECTRON package.jsonpackage.json "scripts": { "start": "electron ." } # npm launch npm run start # or # global installation electron . # or # local installation npx electron .
  • 24.
  • 25. PACKAGINGPACKAGING create asar archive copy archive in electron folder rename electron con gure icon compile ecc...
  • 26. INSTALLING ELECTRON-BUILDERINSTALLING ELECTRON-BUILDER package.jsonpackage.json # globally npm install -g electron-builder # use with `electron-builder` # or # local dependency npm install --save-dev electron-builder # use with `npx electron-builder` "scripts": { "dist": "electron-builder -mwl", "pack": "electron-builder -mwl --dir" },
  • 27. CONFIGURING ELECTRON-BUILDERCONFIGURING ELECTRON-BUILDER electron-builder.ymlelectron-builder.yml appId: electron.sample.2020 productName: Electron Sample 2020 copyright: Copyright © 2020 ${author} icon: icons/icon.png files: - electron/**/* - www/**/* mac: category: public.app-category.utilities
  • 28. CONFIGURING ELECTRON-BUILDERCONFIGURING ELECTRON-BUILDER electron-builder.ymlelectron-builder.yml # ... mac: category: public.app-category.utilities target: dmg win: target: nsis linux: target: AppImage
  • 29. USING ELECTRON-BUILDERUSING ELECTRON-BUILDER BUT WAITBUT WAIT On Linux and Windows you cannot sign macOS apps On Linux and Windows you cannot build DMG archive for macOS npm run pack # electron-builder -mwl --dir # or npm run dist # electron-builder -mwl skipped macOS application code signing reason=supported only on macOS
  • 30.
  • 31. TIP: LINKSTIP: LINKS // electron/main.js const { shell } = require('electron') // ... // open new-window externally app.on('ready', () => { win.webContents.on('new-window', (e, url) => { e.preventDefault() shell.openExternal(url) }) })
  • 32. TIP: WEB TOOLSTIP: WEB TOOLS How to disable web tools in production? // electron/main.js // ... win = new BrowserWindow({ // ... webPreferences: { devTools: false, // ... } // ... })
  • 33. TIP: NOTIFICATIONSTIP: NOTIFICATIONS // www/js/script.js const btnNotification = document.getElementById('btnNotification' btnNotification.onclick = () => { const myNotification = new Notification('Title', { body: 'Lorem Ipsum Dolor Sit Amet' }) myNotification.onclick = () => { console.log('Notification clicked') } }
  • 34. TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION SyncSync // electron/main.js const { ipcMain } = require('electron') ipcMain.on('synchronous-message', (event, arg) => { console.log(arg) setTimeout(() => { event.returnValue = 'pong sync' }, 1000) })
  • 35. TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION SyncSync // www/js/script.js const { ipcRenderer } = require('electron') const btnIpcSync = document.getElementById('btnIpcSync') btnIpcSync.onclick = () => { console.log( ipcRenderer.sendSync('synchronous-message', 'ping sync') ) }
  • 36. TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION AsyncAsync // electron/main.js const { ipcMain } = require('electron') ipcMain.on('asynchronous-message', (event, arg) => { console.log(arg) setTimeout(() => { event.reply('asynchronous-reply', 'pong async') }, 1000) })
  • 37. TIP: IPC COMMUNICATIONTIP: IPC COMMUNICATION AsyncAsync // www/js/script.js const { ipcRenderer } = require('electron') ipcRenderer.on('asynchronous-reply', (event, arg) => { console.log(arg) }) const btnIpcAsync = document.getElementById('btnIpcAsync') btnIpcAsync.onclick = () => { ipcRenderer.send('asynchronous-message', 'ping async') }
  • 38. TIP: PROGRESS BARTIP: PROGRESS BAR Setting the parameter to a value below zero (like -1) will remove the progress bar while setting it to a value higher than one (like 2) will switch the progress bar to intermediate mode. // electron/main.js win.setProgressBar(value)
  • 39. TIP: PROGRESS BARTIP: PROGRESS BAR // electron/main.js const { ipcMain } = require('electron') ipcMain.on('test-progress-bar', (event, arg) => { let progressVal = 0 const interval = setInterval(() => { progressVal += 1 win.setProgressBar(progressVal / 100) if (progressVal == 100) { clearInterval(interval) win.setProgressBar(-1) event.reply('test-progress-bar-reply') } }, 100) })
  • 40. TIP: PROGRESS BARTIP: PROGRESS BAR // www/js/script.js const { ipcRenderer } = require('electron') ipcRenderer.on('test-progress-bar-reply', () => { new Notification('Progress completed', { body: 'All progress are completed' }) }) const btnIpcProgress = document.getElementById('btnIpcProgress') btnIpcProgress.onclick = () => { ipcRenderer.send('test-progress-bar') }
  • 41. TIP: CREATE-REACT-APP COMPATIBILITYTIP: CREATE-REACT-APP COMPATIBILITY Adding electron-builder to a create-react-app project could be very painful. ⨯ Application entry file "build/electron.js" in the "path/repo/dist/mac/My.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
  • 42. TIP: CREATE-REACT-APP COMPATIBILITYTIP: CREATE-REACT-APP COMPATIBILITY Fix:Fix: http://tiny.cc/5jxyizhttp://tiny.cc/5jxyiz # use yarn yarn install --dev electron yarn install --dev electron-builder yarn run ... // add `homepage` in `package.json` "homepage": "./", # move `electron/main.js` in `public` folder electron/main.js => public/electron.js
  • 43. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP Auto-updatable Targets macOS: DMG macOS application must be signed in order for auto updating to work Linux: AppImage Windows: NSIS https://www.electron.build/auto-updatehttps://www.electron.build/auto-update
  • 44. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP ConfigurationConfiguration 1. Install electron-updater as an app dependency. 2. Con gure publish in electron-builder.yml. npm install --save electron-updater publish: provider: generic url: https://your.release.website/release_path/ mac: target: [dmg, zip] # add zip, important!
  • 45. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP Configuration (electron/main.js)Configuration (electron/main.js) 3. Use autoUpdater from electron-updater instead of electron: 4. Call update function const { autoUpdater } = require('electron-updater') app.on('ready', () => { setTimeout(() => { autoUpdater.checkForUpdatesAndNotify() }, 1000) })
  • 46. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP NotificationsNotifications
  • 47. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP Advanced usageAdvanced usage // www/js/script.js const { ipcRenderer } = require('electron') ipcRenderer.on('update-message', function (event, { body, timeout const notification = new Notification('AutoUpdate', { body }) setTimeout(() => { notification.close() }, timeout) })
  • 48. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP Advanced usageAdvanced usage // electron/main.js function sendStatusToWindow(text, timeout = 20000) { win.webContents.send('update-message', { body: text, timeout, }) }
  • 49. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP Advanced usageAdvanced usage // electron/main.js autoUpdater.on('checking-for-update', () => { sendStatusToWindow('Checking for update...') }) autoUpdater.on('update-available', (info) => { sendStatusToWindow('Update available.') }) autoUpdater.on('update-not-available', (info) => { sendStatusToWindow('Update not available.') })
  • 50. TIP: AUTO-UPDATE YOUR APPTIP: AUTO-UPDATE YOUR APP Advanced usageAdvanced usage // electron/main.js autoUpdater.on('error', (err) => { sendStatusToWindow('Error in auto-updater. ' + err) }) autoUpdater.on('download-progress', (progressObj) => { let log_message = "Download speed: " + progressObj.bytesPerSeco log_message = log_message + ' - Downloaded ' + progressObj.perc log_message = log_message + ' (' + progressObj.transferred + "/ sendStatusToWindow(log_message) }) autoUpdater.on('update-downloaded', (info) => { sendStatusToWindow('Update downloaded') })